Spaces:
Running
Running
salomonsky
commited on
Commit
•
0a48097
1
Parent(s):
581837a
Update app.py
Browse files
app.py
CHANGED
@@ -42,12 +42,21 @@ def get_upscale_finegrain(prompt, img_path, upscale_factor):
|
|
42 |
return None
|
43 |
|
44 |
async def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model, process_lora):
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
if process_upscale:
|
47 |
upscale_image_path = get_upscale_finegrain(prompt, image_path, upscale_factor)
|
48 |
-
upscale_image = Image.open(upscale_image_path)
|
49 |
-
upscale_image.save("upscale_image.jpg", format="JPEG")
|
50 |
return [image_path, "upscale_image.jpg"]
|
|
|
|
|
51 |
|
52 |
css = """
|
53 |
#col-container{ margin: 0 auto; max-width: 1024px;}
|
|
|
42 |
return None
|
43 |
|
44 |
async def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model, process_lora):
|
45 |
+
model = enable_lora(lora_model, basemodel) if process_lora else basemodel
|
46 |
+
image, seed = await generate_image(prompt, model, "", width, height, scales, steps, seed)
|
47 |
+
if image is None:
|
48 |
+
return [None, None]
|
49 |
+
|
50 |
+
image_path = "temp_image.jpg"
|
51 |
+
image.save(image_path, format="JPEG")
|
52 |
+
|
53 |
if process_upscale:
|
54 |
upscale_image_path = get_upscale_finegrain(prompt, image_path, upscale_factor)
|
55 |
+
upscale_image = Image.open(upscale_image_path)
|
56 |
+
upscale_image.save("upscale_image.jpg", format="JPEG")
|
57 |
return [image_path, "upscale_image.jpg"]
|
58 |
+
else:
|
59 |
+
return [image_path, image_path]
|
60 |
|
61 |
css = """
|
62 |
#col-container{ margin: 0 auto; max-width: 1024px;}
|