lots-of-things / Story2Hallucination

GNU General Public License v3.0
146 stars 19 forks source link

It's possible to display text by sentence? #1

Open gamanox opened 3 years ago

gamanox commented 3 years ago

Hi, excellent work, I'm looking to set the span dinamically by the length of a sentence, for example this verse:

The moon has a face like the clock in the hall, She shines on thieves on the garden wall, On streets and fields and harbour quays, And birdies asleep in the forks of the trees,

Could be possible? thank you very much

stedn commented 3 years ago

Hey, I made a new notebook that works that way here: https://github.com/lots-of-things/Story2Hallucination/blob/main/Story2Hallucination_preset.ipynb

I didn't test it so there might be bugs, but this should do it. Could you test it and let me know if it works?

gamanox commented 3 years ago

OMG, let me test it out, thank you very much, keep you posted. Thanks again

gamanox commented 3 years ago

It works so much better,

Screen Shot 2021-02-24 at 12 29 52

let me do more testing before closing the issue.

stedn commented 3 years ago

awesome, glad it's working, I might try using it that way more. I did that for one of my earlier experiments, but then I switched to incrementing through one word at a time just for simplicity.

impulsecorp commented 3 years ago

I am able to run your regular version fine in Colab, but when I import this "preset" version into Colab and run it I get this error:


NameError Traceback (most recent call last)

in () 62 similarity = 0.9 63 ---> 64 words = all_text.split() 65 all_text_list = ["The moon has a face like the clock in the hall,", 66 "She shines on thieves on the garden wall,", NameError: name 'all_text' is not defined
stedn commented 3 years ago

Line 64 just needed to be removed. I've updated the file in the repo.

impulsecorp commented 3 years ago

I get this error now:

NameError Traceback (most recent call last)

in () 70 last_one = 0 71 rand = 0 ---> 72 model.text = " ".join(words[:span]) 73 model.encoded_text = tokenize(model.text).cuda() 74 for j in range(burnin): NameError: name 'words' is not defined
jef84142 commented 3 years ago

I was having the same issue, but here is an edited chuck of code to replace the pieces that arent working!

filename = TEXT.replace(' ', '_')

all_text_list = ["The moon has a face like the clock in the hall,", "She shines on thieves on the garden wall,", "On streets and fields and harbour quays,", "And birdies asleep in the forks of the trees,"]

burnin=20 # checkin_gap = 10 long_sim_gap = 10 span = 6 iterations = 100 display_gap = 50 similarity = 0.9

words = all_text_list all_text_list = [" ".join(words[i:i+span]) for i in range(0, len(words), span)] all_text_full = all_text_list

jef84142 commented 3 years ago

Still having some issues, that fixes the error, but prints the whole text on every image. sorry :(

jef84142 commented 3 years ago

Update! I figured out a solution/workaround without editing the original text after the test where it says "span= 6" this value can be edited to set the number of words that appear on the screen. You can use a hyphen "-" to take the place of the word so if I have the span set to 8 and the sentences I want are "The cat hopped off the couch" "The cat landed on the floor with grace" I can make them print the line separately by doing "- the cat hopped off the couch-" "The cat landed on the floor with grace".

not a perfect fix, but it works for small stories!

kukiui commented 3 years ago

it worked for me yesterday, i tried to change the story again and it does not work anymore. I get the same error: 73 model.text = " ".join(words[:span]) NameError: name 'words' is not defined Even bigger problem is that I changed it back and now it wont work in anyway. Anybody has an ideea?

skabbit commented 3 years ago

there is multiple problems with this code, as if your sentence is longer than width, you also need to add some changes.