Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -42,6 +42,8 @@ def process(data, api, api_key):
|
|
42 |
# Initial check without blocking, useful for quick tasks
|
43 |
status = run_request.status()
|
44 |
print(f"Initial job status: {status}")
|
|
|
|
|
45 |
|
46 |
if status != "COMPLETED":
|
47 |
# Polling with timeout for long-running tasks
|
@@ -51,6 +53,11 @@ def process(data, api, api_key):
|
|
51 |
print(f"Job output: {output}")
|
52 |
except Exception as e:
|
53 |
print(f"An error occurred: {e}")
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
|
56 |
image_data = output['image']
|
@@ -63,7 +70,13 @@ def process(data, api, api_key):
|
|
63 |
|
64 |
def process_generate(fore, prompt, image_width, image_height, intensity, mode, refprompt):
|
65 |
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
forestr = image_to_base64(fore.convert("RGBA"))
|
68 |
|
69 |
|
@@ -155,7 +168,7 @@ with block:
|
|
155 |
image_height.change(fn=update_value, inputs=image_height, outputs=image_height)
|
156 |
|
157 |
with gr.Row():
|
158 |
-
intensity = gr.Slider(label="Refiner Strength", minimum=1.0, maximum=7.0, value=3.0, step=0.
|
159 |
intensity.change(fn=update_value, inputs=intensity, outputs=intensity)
|
160 |
generate_button = gr.Button(value="Generate")
|
161 |
|
|
|
42 |
# Initial check without blocking, useful for quick tasks
|
43 |
status = run_request.status()
|
44 |
print(f"Initial job status: {status}")
|
45 |
+
if status=="IN_QUEUE":
|
46 |
+
raise gr.Info("Queued 🚶🚶🚶🚶!", duration=15)
|
47 |
|
48 |
if status != "COMPLETED":
|
49 |
# Polling with timeout for long-running tasks
|
|
|
53 |
print(f"Job output: {output}")
|
54 |
except Exception as e:
|
55 |
print(f"An error occurred: {e}")
|
56 |
+
status = run_request.status()
|
57 |
+
if status=="FAILED":
|
58 |
+
raise gr.Error("An error occured 💥!", duration=5)
|
59 |
+
if status=="TIMED_OUT":
|
60 |
+
raise gr.Error("Sorry we could not secure a worker for you ⏳! Try again", duration=5)
|
61 |
|
62 |
|
63 |
image_data = output['image']
|
|
|
70 |
|
71 |
def process_generate(fore, prompt, image_width, image_height, intensity, mode, refprompt):
|
72 |
|
73 |
+
size = fore.size
|
74 |
+
if size[0]*size[1]<=(768*768):
|
75 |
+
gr.Warning("ℹ️ The input image resolution is low, it might lead to some deformation!")
|
76 |
+
|
77 |
+
if size[0]*size[1]>(1500*1500):
|
78 |
+
gr.Warning("ℹ️ The input image size is too big, I will lower it!")
|
79 |
+
|
80 |
forestr = image_to_base64(fore.convert("RGBA"))
|
81 |
|
82 |
|
|
|
168 |
image_height.change(fn=update_value, inputs=image_height, outputs=image_height)
|
169 |
|
170 |
with gr.Row():
|
171 |
+
intensity = gr.Slider(label="Refiner Strength", minimum=1.0, maximum=7.0, value=3.0, step=0.5)
|
172 |
intensity.change(fn=update_value, inputs=intensity, outputs=intensity)
|
173 |
generate_button = gr.Button(value="Generate")
|
174 |
|