Update backup-app.py
Browse files- backup-app.py +18 -0
backup-app.py
CHANGED
@@ -8,6 +8,24 @@ stable_diffusion = gr.Blocks.load(name="spaces/runwayml/stable-diffusion-v1-5")
|
|
8 |
def get_images(prompt):
|
9 |
gallery_dir = stable_diffusion(prompt, fn_index=2)
|
10 |
sd_output = [os.path.join(gallery_dir, image) for image in os.listdir(gallery_dir)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
return sd_output, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
12 |
|
13 |
def get_prompts(prompt_text):
|
|
|
8 |
def get_images(prompt):
|
9 |
gallery_dir = stable_diffusion(prompt, fn_index=2)
|
10 |
sd_output = [os.path.join(gallery_dir, image) for image in os.listdir(gallery_dir)]
|
11 |
+
|
12 |
+
# Save the prompt to a text file
|
13 |
+
with open("prompt_log.txt", "a") as f:
|
14 |
+
f.write(prompt + "\n")
|
15 |
+
|
16 |
+
return sd_output, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
17 |
+
def load_past_prompts():
|
18 |
+
# Read from the text file and return the content
|
19 |
+
if os.path.exists("prompt_log.txt"):
|
20 |
+
with open("prompt_log.txt", "r") as f:
|
21 |
+
return f.read()
|
22 |
+
else:
|
23 |
+
return "No past prompts."
|
24 |
+
|
25 |
+
|
26 |
+
def get_images_old(prompt):
|
27 |
+
gallery_dir = stable_diffusion(prompt, fn_index=2)
|
28 |
+
sd_output = [os.path.join(gallery_dir, image) for image in os.listdir(gallery_dir)]
|
29 |
return sd_output, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
30 |
|
31 |
def get_prompts(prompt_text):
|