Spaces:
Running
on
Zero
Running
on
Zero
wjm55
commited on
Commit
·
d5836e4
1
Parent(s):
71089ff
fixed input of create zip
Browse files
app.py
CHANGED
@@ -269,15 +269,17 @@ with gr.Blocks(css=css) as demo:
|
|
269 |
download_output = gr.File(label="Download")
|
270 |
|
271 |
# Modify create_zip to use the state data
|
272 |
-
def create_zip(image,
|
273 |
# Validate inputs
|
274 |
-
if not fname or
|
275 |
return None
|
276 |
|
277 |
try:
|
278 |
# Convert numpy array to PIL Image if needed
|
279 |
if isinstance(image, np.ndarray):
|
280 |
image = Image.fromarray(image)
|
|
|
|
|
281 |
|
282 |
with tempfile.TemporaryDirectory() as temp_dir:
|
283 |
# Save image
|
@@ -324,7 +326,7 @@ with gr.Blocks(css=css) as demo:
|
|
324 |
# Update the download button click handler to include state
|
325 |
download_btn.click(
|
326 |
create_zip,
|
327 |
-
inputs=[input_img,
|
328 |
outputs=[download_output]
|
329 |
)
|
330 |
|
|
|
269 |
download_output = gr.File(label="Download")
|
270 |
|
271 |
# Modify create_zip to use the state data
|
272 |
+
def create_zip(image, fname, ocr_result):
|
273 |
# Validate inputs
|
274 |
+
if not fname or image is None: # Changed the validation check
|
275 |
return None
|
276 |
|
277 |
try:
|
278 |
# Convert numpy array to PIL Image if needed
|
279 |
if isinstance(image, np.ndarray):
|
280 |
image = Image.fromarray(image)
|
281 |
+
elif not isinstance(image, Image.Image):
|
282 |
+
return None
|
283 |
|
284 |
with tempfile.TemporaryDirectory() as temp_dir:
|
285 |
# Save image
|
|
|
326 |
# Update the download button click handler to include state
|
327 |
download_btn.click(
|
328 |
create_zip,
|
329 |
+
inputs=[input_img, filename, ocr_state],
|
330 |
outputs=[download_output]
|
331 |
)
|
332 |
|