Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -56,7 +56,8 @@ def save_image(image: PIL.Image.Image, prompt: str) -> str:
|
|
56 |
return filename
|
57 |
|
58 |
def get_image_gallery():
|
59 |
-
|
|
|
60 |
|
61 |
@spaces.GPU(enable_queue=True)
|
62 |
def generate(prompt: str, negative_prompt: str = "", prompt_2: str = "", negative_prompt_2: str = "", use_negative_prompt: bool = False, use_prompt_2: bool = False, use_negative_prompt_2: bool = False, seed: int = 0, width: int = 1024, height: int = 1024, guidance_scale_base: float = 5.0, guidance_scale_refiner: float = 5.0, num_inference_steps_base: int = 25, num_inference_steps_refiner: int = 25, apply_refiner: bool = False, progress=gr.Progress(track_tqdm=True)) -> PIL.Image.Image:
|
@@ -70,7 +71,7 @@ def generate(prompt: str, negative_prompt: str = "", prompt_2: str = "", negativ
|
|
70 |
else:
|
71 |
latents = pipe(prompt=prompt, negative_prompt=negative_prompt, prompt_2=prompt_2, negative_prompt_2=negative_prompt_2, width=width, height=height, guidance_scale=guidance_scale_base, num_inference_steps=num_inference_steps_base, generator=generator, output_type="latent").images
|
72 |
image = refiner(prompt=prompt, negative_prompt=negative_prompt, prompt_2=prompt_2, negative_prompt_2=negative_prompt_2, guidance_scale=guidance_scale_refiner, num_inference_steps=num_inference_steps_refiner, image=latents, generator=generator).images[0]
|
73 |
-
save_image(image, prompt)
|
74 |
return image, get_image_gallery()
|
75 |
|
76 |
examples = [f"{random.choice(['Impressionist', 'Cubist', 'Surrealist', 'Abstract Expressionist', 'Pop Art', 'Minimalist', 'Baroque', 'Art Nouveau', 'Pointillist', 'Fauvism'])} painting of a majestic lighthouse on a rocky coast. Use bold brushstrokes and a vibrant color palette to capture the interplay of light and shadow as the lighthouse beam cuts through a stormy night sky.",
|
|
|
56 |
return filename
|
57 |
|
58 |
def get_image_gallery():
|
59 |
+
image_files = glob.glob("*.png")
|
60 |
+
return sorted([(file, file) for file in image_files], key=lambda x: os.path.getmtime(x[0]), reverse=True)
|
61 |
|
62 |
@spaces.GPU(enable_queue=True)
|
63 |
def generate(prompt: str, negative_prompt: str = "", prompt_2: str = "", negative_prompt_2: str = "", use_negative_prompt: bool = False, use_prompt_2: bool = False, use_negative_prompt_2: bool = False, seed: int = 0, width: int = 1024, height: int = 1024, guidance_scale_base: float = 5.0, guidance_scale_refiner: float = 5.0, num_inference_steps_base: int = 25, num_inference_steps_refiner: int = 25, apply_refiner: bool = False, progress=gr.Progress(track_tqdm=True)) -> PIL.Image.Image:
|
|
|
71 |
else:
|
72 |
latents = pipe(prompt=prompt, negative_prompt=negative_prompt, prompt_2=prompt_2, negative_prompt_2=negative_prompt_2, width=width, height=height, guidance_scale=guidance_scale_base, num_inference_steps=num_inference_steps_base, generator=generator, output_type="latent").images
|
73 |
image = refiner(prompt=prompt, negative_prompt=negative_prompt, prompt_2=prompt_2, negative_prompt_2=negative_prompt_2, guidance_scale=guidance_scale_refiner, num_inference_steps=num_inference_steps_refiner, image=latents, generator=generator).images[0]
|
74 |
+
filename = save_image(image, prompt)
|
75 |
return image, get_image_gallery()
|
76 |
|
77 |
examples = [f"{random.choice(['Impressionist', 'Cubist', 'Surrealist', 'Abstract Expressionist', 'Pop Art', 'Minimalist', 'Baroque', 'Art Nouveau', 'Pointillist', 'Fauvism'])} painting of a majestic lighthouse on a rocky coast. Use bold brushstrokes and a vibrant color palette to capture the interplay of light and shadow as the lighthouse beam cuts through a stormy night sky.",
|