Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import os
|
3 |
import sys
|
4 |
from pathlib import Path
|
|
|
5 |
|
6 |
def load_models_from_file(filename):
|
7 |
with open(filename, 'r') as f:
|
@@ -28,10 +29,32 @@ def set_model(current_model):
|
|
28 |
return gr.update(label=(f"{current_model}"))
|
29 |
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
def send_it1(inputs, model_choice):
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
css=""""""
|
36 |
|
37 |
|
@@ -102,6 +125,10 @@ with gr.Blocks(css=css) as myface:
|
|
102 |
input_text=gr.Textbox(label="Prompt Idea",lines=2)
|
103 |
use_short=gr.Button("Use Short Prompt")
|
104 |
see_prompts=gr.Button("Extend Idea")
|
|
|
|
|
|
|
|
|
105 |
|
106 |
def short_prompt(inputs):
|
107 |
return(inputs)
|
|
|
2 |
import os
|
3 |
import sys
|
4 |
from pathlib import Path
|
5 |
+
from PIL import Image
|
6 |
|
7 |
def load_models_from_file(filename):
|
8 |
with open(filename, 'r') as f:
|
|
|
29 |
return gr.update(label=(f"{current_model}"))
|
30 |
|
31 |
|
32 |
+
def list_saved_prompts_and_images():
|
33 |
+
saved_prompts = os.listdir('saved_prompts')
|
34 |
+
saved_images = os.listdir('saved_images')
|
35 |
+
|
36 |
+
prompt_image_pairs = []
|
37 |
+
for prompt_file in saved_prompts:
|
38 |
+
prompt_path = os.path.join('saved_prompts', prompt_file)
|
39 |
+
image_path = os.path.join('saved_images', f"{prompt_file[:-4]}.png") # Remove .txt and add .png
|
40 |
+
if os.path.exists(image_path):
|
41 |
+
with open(prompt_path, 'r') as f:
|
42 |
+
prompt = f.read()
|
43 |
+
image = Image.open(image_path)
|
44 |
+
prompt_image_pairs.append((prompt, image))
|
45 |
+
|
46 |
+
return prompt_image_pairs
|
47 |
+
|
48 |
def send_it1(inputs, model_choice):
|
49 |
+
proc1 = models2[model_choice]
|
50 |
+
output1 = proc1(inputs)
|
51 |
+
# ... Existing code for directory creation and file saving ...
|
52 |
+
|
53 |
+
# List all saved prompts and images after generating a new one
|
54 |
+
prompt_image_pairs = list_saved_prompts_and_images()
|
55 |
+
|
56 |
+
return output1, prompt_image_pairs
|
57 |
+
|
58 |
css=""""""
|
59 |
|
60 |
|
|
|
125 |
input_text=gr.Textbox(label="Prompt Idea",lines=2)
|
126 |
use_short=gr.Button("Use Short Prompt")
|
127 |
see_prompts=gr.Button("Extend Idea")
|
128 |
+
|
129 |
+
with gr.Row():
|
130 |
+
with gr.Column(scale=100):
|
131 |
+
saved_output = gr.Custom(type="custom", label="Saved Prompts and Images")
|
132 |
|
133 |
def short_prompt(inputs):
|
134 |
return(inputs)
|