Spaces:
Running
Running
salomonsky
commited on
Commit
•
ac36fcc
1
Parent(s):
b0241f6
Update app.py
Browse files
app.py
CHANGED
@@ -66,20 +66,38 @@ async def generate_image(
|
|
66 |
|
67 |
return image, seed
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
async def upscale_image(image, upscale_factor):
|
70 |
try:
|
71 |
-
result =
|
72 |
prompt="",
|
73 |
-
|
74 |
-
|
75 |
-
guidance_scale=3.5,
|
76 |
-
num_inference_steps=18,
|
77 |
-
model="finegrain/finegrain-image-enhancer"
|
78 |
)
|
79 |
except Exception as e:
|
80 |
raise gr.Error(f"Error in {e}")
|
81 |
|
82 |
-
return result
|
83 |
|
84 |
async def gen(
|
85 |
prompt:str,
|
|
|
66 |
|
67 |
return image, seed
|
68 |
|
69 |
+
def get_upscale_finegrain(prompt, img_path, upscale_factor):
|
70 |
+
client = Client("finegrain/finegrain-image-enhancer")
|
71 |
+
result = client.predict(
|
72 |
+
input_image=handle_file(img_path),
|
73 |
+
prompt=prompt,
|
74 |
+
negative_prompt="",
|
75 |
+
seed=42,
|
76 |
+
upscale_factor=upscale_factor,
|
77 |
+
controlnet_scale=0.6,
|
78 |
+
controlnet_decay=1,
|
79 |
+
condition_scale=6,
|
80 |
+
tile_width=112,
|
81 |
+
tile_height=144,
|
82 |
+
denoise_strength=0.35,
|
83 |
+
num_inference_steps=18,
|
84 |
+
solver="DDIM",
|
85 |
+
api_name="/process"
|
86 |
+
)
|
87 |
+
print(result)
|
88 |
+
return result[1]
|
89 |
+
|
90 |
async def upscale_image(image, upscale_factor):
|
91 |
try:
|
92 |
+
result = get_upscale_finegrain(
|
93 |
prompt="",
|
94 |
+
img_path=image,
|
95 |
+
upscale_factor=upscale_factor
|
|
|
|
|
|
|
96 |
)
|
97 |
except Exception as e:
|
98 |
raise gr.Error(f"Error in {e}")
|
99 |
|
100 |
+
return result
|
101 |
|
102 |
async def gen(
|
103 |
prompt:str,
|