Spaces:
Runtime error
Runtime error
Commit ·
6af3a2a
1
Parent(s): 505d57d
rm ideas.txt
Browse files2 unmodified lines345678910111213141516171819202111 unmodified lines3334353637383940414243442 unmodified linesgpt2_pipe = pipeline('text-generation', model='Gustavosta/MagicPrompt-Stable-Diffusion', tokenizer='gpt2')with open("ideas.txt", "r") as f:line = f.readlines()def generate(starting_text):seed = random.randint(100, 1000000)set_seed(seed)if starting_text == "":starting_text: str = line[random.randrange(0, len(line))].replace("\n", "").lower().capitalize()starting_text: str = re.sub(r"[,:\-–.!;?_]", '', starting_text)response = gpt2_pipe(starting_text, max_length=(len(starting_text) + random.randint(60, 90)), num_return_sequences=4)response_list = []for x in response:resp = x['generated_text'].strip()11 unmodified linestxt = grad.Textbox(lines=1, label="Initial Text", placeholder="English Text here")out = grad.Textbox(lines=4, label="Generated Prompts")examples = []for x in range(8):examples.append(line[random.randrange(0, len(line))].replace("\n", "").lower().capitalize())title = "Stable Diffusion Prompt Generator"description = 'This is a demo of the model series: "MagicPrompt", in this case, aimed at: "Stable Diffusion". To use it, simply submit your text or click on one of the examples.<br><br>To learn more about the model, [click here]{https://huggingface.co/Gustavosta/MagicPrompt-Stable-Diffusion}.<br>'grad.Interface(fn=generate,inputs=txt,2 unmodified lines3456789101112131415161718192011 unmodified lines32333435363738392 unmodified linesgpt2_pipe = pipeline('text-generation', model='Gustavosta/MagicPrompt-Stable-Diffusion', tokenizer='gpt2')examples = ['Secret Girl', 'The Toad and the Peter Pan', 'Space is Haunting', 'The Journey At', 'The She Wrath', 'Monster-God Wrath', 'Embracing the Grace']def generate(starting_text):seed = random.randint(100, 100000)set_seed(seed)if starting_text == "":starting_text: str = random.choice(examples).lower().capitalize()starting_text: str = re.sub(r"[,:\-–.!;?_]", '', starting_text)response = gpt2_pipe(starting_text, max_length=(len(starting_text) + random.randint(50, 80)), num_return_sequences=4)response_list = []for x in response:resp = x['generated_text'].strip()11 unmodified linestxt = grad.Textbox(lines=1, label="Initial Text", placeholder="English Text here")out = grad.Textbox(lines=4, label="Generated Prompts")title = "Stable Diffusion Prompt Generator"description = 'This is a demo of the model series: "MagicPrompt", in this case, aimed at: "Stable Diffusion". To use it, simply submit your text or click on one of the examples. To learn more about the model, [click here](https://huggingface.co/Gustavosta/MagicPrompt-Stable-Diffusion).<br>'grad.Interface(fn=generate,inputs=txt,
app.py+5-10