Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ import base64
|
|
14 |
from gradio_client import Client, handle_file
|
15 |
import cv2
|
16 |
from moviepy.editor import VideoFileClip
|
|
|
17 |
# ๋ก๊น
์ค์
|
18 |
logging.basicConfig(level=logging.INFO)
|
19 |
|
@@ -36,7 +37,6 @@ for attempt in range(max_retries):
|
|
36 |
print("Failed to connect after multiple attempts.")
|
37 |
raise # ๋ชจ๋ ์๋ ์คํจ ์ ์์ธ ๋ฐ์
|
38 |
|
39 |
-
|
40 |
# ๊ฐค๋ฌ๋ฆฌ ์ ์ฅ ๋๋ ํ ๋ฆฌ ์ค์
|
41 |
GALLERY_DIR = "gallery"
|
42 |
GALLERY_JSON = "gallery.json"
|
@@ -71,15 +71,20 @@ def save_to_gallery(video_path, prompt):
|
|
71 |
|
72 |
return new_video_path
|
73 |
|
74 |
-
|
75 |
-
|
76 |
def load_gallery():
|
77 |
if os.path.exists(GALLERY_JSON):
|
78 |
with open(GALLERY_JSON, "r") as f:
|
79 |
gallery = json.load(f)
|
80 |
return [{"image": item["video"], "caption": item["prompt"]} for item in reversed(gallery)]
|
81 |
return []
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
def respond(image, prompt, steps, cfg_scale, eta, fs, seed, video_length):
|
84 |
logging.info(f"Received prompt: {prompt}, steps: {steps}, cfg_scale: {cfg_scale}, "
|
85 |
f"eta: {eta}, fs: {fs}, seed: {seed}, video_length: {video_length}")
|
@@ -120,15 +125,14 @@ footer {
|
|
120 |
}
|
121 |
"""
|
122 |
|
123 |
-
|
124 |
examples = [
|
125 |
-
["A glamorous young woman with long, wavy blonde hair and smokey eye makeup, posing in a luxury hotel room. She
|
126 |
["A fit male fitness influencer with short dark hair and stubble, standing shirtless in a modern gym. He has defined abs and arm muscles, and is holding a protein shake in one hand and a card that says 'openfree.ai' in the other. Bright, clean lighting highlights his physique.", "q2.webp"],
|
127 |
-
["A bohemian-style female travel blogger with sun-kissed skin and messy beach waves, sitting on a tropical beach at sunset. She
|
128 |
-
["A trendy male fashion influencer with perfectly styled hair and designer stubble, posing on a city street. He
|
129 |
-
["A fresh-faced young female beauty guru with freckles and natural makeup, sitting at a vanity covered in cosmetics. She
|
130 |
-
["A stylish young woman with long, wavy ombre hair and winged eyeliner, posing in front of a neon-lit city skyline at night. She
|
131 |
-
["Create a surreal advertisement poster for a fictional time travel agency. The background should depict a swirling vortex of clock faces and historical landmarks from different eras. In the foreground, place large, bold text that reads
|
132 |
["Photo realistic scene inspired by LOTR: [A tiny red dragon sleeps curled up in a nest on a medieval wizard's table]. Shot with a macro lens (f/2.8, 50mm) and a Canon EOSR5, the soft focus captures [the cozy morning light filtering through a near by window]. The pastel colors and whimsical steam shapes enhance the serene atmosphere, evoking a DnD RPG setting. The image is rendered in 16K and 8K, highlighting [the intricate details and medieval charm].", "q8.webp"],
|
133 |
["์ฌ๊ธ๋ผ์ค๋ฅผ ์ฐฉ์ฉํ ๊ท์ฌ์ด ๊ฐ์์ง๊ฐ 'Openfree.ai'๋ผ๊ณ ์ฐ์ฌ์ง ํ์งํ์ ๋ค๊ณ ์๋ค.", "q9.webp"],
|
134 |
["๋ฏธ๋ ์ ์ธ ๋์์ ํด์ง๋ ํ๊ฒฝ", "q10.webp"],
|
@@ -146,7 +150,10 @@ examples = [
|
|
146 |
|
147 |
def use_prompt_and_image(prompt, image):
|
148 |
return prompt, image
|
149 |
-
|
|
|
|
|
|
|
150 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
151 |
with gr.Tab("Generate"):
|
152 |
with gr.Row():
|
@@ -177,8 +184,6 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
177 |
outputs=[input_text, input_image]
|
178 |
)
|
179 |
|
180 |
-
|
181 |
-
|
182 |
with gr.Tab("Gallery"):
|
183 |
gallery = gr.Gallery(
|
184 |
label="Generated Videos",
|
@@ -187,20 +192,11 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
187 |
columns=[5],
|
188 |
rows=[3],
|
189 |
object_fit="contain",
|
190 |
-
height="auto"
|
|
|
191 |
)
|
192 |
selected_video = gr.Video(label="Selected Video")
|
193 |
refresh_btn = gr.Button("Refresh Gallery")
|
194 |
-
|
195 |
-
def update_gallery():
|
196 |
-
gallery_items = load_gallery()
|
197 |
-
return [
|
198 |
-
(item['image'], item['caption'])
|
199 |
-
for item in gallery_items
|
200 |
-
]
|
201 |
-
|
202 |
-
def show_video(evt: gr.SelectData):
|
203 |
-
return evt.value[0] # ์ ํ๋ ๋น๋์ค์ ๊ฒฝ๋ก ๋ฐํ
|
204 |
|
205 |
refresh_btn.click(fn=update_gallery, inputs=None, outputs=gallery)
|
206 |
demo.load(fn=update_gallery, inputs=None, outputs=gallery)
|
@@ -217,4 +213,4 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
217 |
)
|
218 |
|
219 |
if __name__ == "__main__":
|
220 |
-
demo.launch()
|
|
|
14 |
from gradio_client import Client, handle_file
|
15 |
import cv2
|
16 |
from moviepy.editor import VideoFileClip
|
17 |
+
|
18 |
# ๋ก๊น
์ค์
|
19 |
logging.basicConfig(level=logging.INFO)
|
20 |
|
|
|
37 |
print("Failed to connect after multiple attempts.")
|
38 |
raise # ๋ชจ๋ ์๋ ์คํจ ์ ์์ธ ๋ฐ์
|
39 |
|
|
|
40 |
# ๊ฐค๋ฌ๋ฆฌ ์ ์ฅ ๋๋ ํ ๋ฆฌ ์ค์
|
41 |
GALLERY_DIR = "gallery"
|
42 |
GALLERY_JSON = "gallery.json"
|
|
|
71 |
|
72 |
return new_video_path
|
73 |
|
|
|
|
|
74 |
def load_gallery():
|
75 |
if os.path.exists(GALLERY_JSON):
|
76 |
with open(GALLERY_JSON, "r") as f:
|
77 |
gallery = json.load(f)
|
78 |
return [{"image": item["video"], "caption": item["prompt"]} for item in reversed(gallery)]
|
79 |
return []
|
80 |
+
|
81 |
+
def update_gallery():
|
82 |
+
gallery_items = load_gallery()
|
83 |
+
return [
|
84 |
+
{"video": item['image'], "caption": item['caption']}
|
85 |
+
for item in gallery_items
|
86 |
+
]
|
87 |
+
|
88 |
def respond(image, prompt, steps, cfg_scale, eta, fs, seed, video_length):
|
89 |
logging.info(f"Received prompt: {prompt}, steps: {steps}, cfg_scale: {cfg_scale}, "
|
90 |
f"eta: {eta}, fs: {fs}, seed: {seed}, video_length: {video_length}")
|
|
|
125 |
}
|
126 |
"""
|
127 |
|
|
|
128 |
examples = [
|
129 |
+
["A glamorous young woman with long, wavy blonde hair and smokey eye makeup, posing in a luxury hotel room. She's wearing a sparkly gold cocktail dress and holding up a white card with 'openfree.ai' written on it in elegant calligraphy. Soft, warm lighting creates a luxurious atmosphere. ", "q1.webp"],
|
130 |
["A fit male fitness influencer with short dark hair and stubble, standing shirtless in a modern gym. He has defined abs and arm muscles, and is holding a protein shake in one hand and a card that says 'openfree.ai' in the other. Bright, clean lighting highlights his physique.", "q2.webp"],
|
131 |
+
["A bohemian-style female travel blogger with sun-kissed skin and messy beach waves, sitting on a tropical beach at sunset. She's wearing a flowy white sundress and holding up a weathered postcard with 'openfree.ai' scrawled on it. Golden hour lighting bathes the scene in warm tones. ", "q3.webp"],
|
132 |
+
["A trendy male fashion influencer with perfectly styled hair and designer stubble, posing on a city street. He's wearing a tailored suit and holding up a sleek black business card with 'openfree.ai' printed in minimalist white font. The background shows blurred city lights, creating a chic urban atmosphere.", "q4.webp"],
|
133 |
+
["A fresh-faced young female beauty guru with freckles and natural makeup, sitting at a vanity covered in cosmetics. She's wearing a pastel pink robe and holding up a makeup palette with 'openfree.ai' written on it in lipstick. Soft, flattering lighting enhances her radiant complexion. ", "q5.webp"],
|
134 |
+
["A stylish young woman with long, wavy ombre hair and winged eyeliner, posing in front of a neon-lit city skyline at night. She's wearing a sleek black leather jacket over a sparkly crop top and holding up a holographic business card that says 'openfree.ai' in futuristic font. The card reflects the colorful neon lights, creating a cyberpunk aesthetic.", "q6.webp"],
|
135 |
+
["Create a surreal advertisement poster for a fictional time travel agency. The background should depict a swirling vortex of clock faces and historical landmarks from different eras. In the foreground, place large, bold text that reads "AI TOURS: YOUR PAST IS OUR FUTURE" in a retro-futuristic font. The text should appear to be partially disintegrating into particles that are being sucked into the time vortex. Include smaller text at the bottom with fictional pricing and the slogan "History is just a ticket away!"", "q7.webp"],
|
136 |
["Photo realistic scene inspired by LOTR: [A tiny red dragon sleeps curled up in a nest on a medieval wizard's table]. Shot with a macro lens (f/2.8, 50mm) and a Canon EOSR5, the soft focus captures [the cozy morning light filtering through a near by window]. The pastel colors and whimsical steam shapes enhance the serene atmosphere, evoking a DnD RPG setting. The image is rendered in 16K and 8K, highlighting [the intricate details and medieval charm].", "q8.webp"],
|
137 |
["์ฌ๊ธ๋ผ์ค๋ฅผ ์ฐฉ์ฉํ ๊ท์ฌ์ด ๊ฐ์์ง๊ฐ 'Openfree.ai'๋ผ๊ณ ์ฐ์ฌ์ง ํ์งํ์ ๋ค๊ณ ์๋ค.", "q9.webp"],
|
138 |
["๋ฏธ๋ ์ ์ธ ๋์์ ํด์ง๋ ํ๊ฒฝ", "q10.webp"],
|
|
|
150 |
|
151 |
def use_prompt_and_image(prompt, image):
|
152 |
return prompt, image
|
153 |
+
|
154 |
+
def show_video(evt: gr.SelectData):
|
155 |
+
return evt.value["video"] if isinstance(evt.value, dict) and "video" in evt.value else None
|
156 |
+
|
157 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
158 |
with gr.Tab("Generate"):
|
159 |
with gr.Row():
|
|
|
184 |
outputs=[input_text, input_image]
|
185 |
)
|
186 |
|
|
|
|
|
187 |
with gr.Tab("Gallery"):
|
188 |
gallery = gr.Gallery(
|
189 |
label="Generated Videos",
|
|
|
192 |
columns=[5],
|
193 |
rows=[3],
|
194 |
object_fit="contain",
|
195 |
+
height="auto",
|
196 |
+
preview=True
|
197 |
)
|
198 |
selected_video = gr.Video(label="Selected Video")
|
199 |
refresh_btn = gr.Button("Refresh Gallery")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
refresh_btn.click(fn=update_gallery, inputs=None, outputs=gallery)
|
202 |
demo.load(fn=update_gallery, inputs=None, outputs=gallery)
|
|
|
213 |
)
|
214 |
|
215 |
if __name__ == "__main__":
|
216 |
+
demo.launch()
|