Spaces:
Running
on
Zero
Running
on
Zero
update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import traceback
|
|
|
2 |
from typing import Optional
|
3 |
import spaces
|
4 |
import gradio as gr
|
@@ -21,6 +22,9 @@ import torch
|
|
21 |
from transformers import AutoModelForCausalLM
|
22 |
from transformers import AutoProcessor
|
23 |
|
|
|
|
|
|
|
24 |
# Define repository and local directory
|
25 |
repo_id = "microsoft/OmniParser-v2.0" # HF repo
|
26 |
local_dir = "weights" # Target local directory
|
@@ -159,6 +163,7 @@ def process(
|
|
159 |
instruction,
|
160 |
) -> Optional[Image.Image]:
|
161 |
|
|
|
162 |
try:
|
163 |
# image_save_path = 'imgs/saved_image_demo.png'
|
164 |
# image_input.save(image_save_path)
|
@@ -250,13 +255,15 @@ def process(
|
|
250 |
)
|
251 |
except:
|
252 |
image_som = image_input
|
253 |
-
|
|
|
254 |
return image_som, str(parsed_content_list)
|
255 |
except Exception as e:
|
256 |
-
|
257 |
traceback.print_exc()
|
258 |
return image_input, 'error in process'
|
259 |
|
|
|
260 |
with gr.Blocks() as demo:
|
261 |
gr.Markdown(MARKDOWN)
|
262 |
with gr.Row():
|
|
|
1 |
import traceback
|
2 |
+
import logging
|
3 |
from typing import Optional
|
4 |
import spaces
|
5 |
import gradio as gr
|
|
|
22 |
from transformers import AutoModelForCausalLM
|
23 |
from transformers import AutoProcessor
|
24 |
|
25 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
26 |
+
logger = logging.getLogger(__name__)
|
27 |
+
|
28 |
# Define repository and local directory
|
29 |
repo_id = "microsoft/OmniParser-v2.0" # HF repo
|
30 |
local_dir = "weights" # Target local directory
|
|
|
163 |
instruction,
|
164 |
) -> Optional[Image.Image]:
|
165 |
|
166 |
+
logger.info("Starting processing.")
|
167 |
try:
|
168 |
# image_save_path = 'imgs/saved_image_demo.png'
|
169 |
# image_input.save(image_save_path)
|
|
|
255 |
)
|
256 |
except:
|
257 |
image_som = image_input
|
258 |
+
|
259 |
+
logger.info("finish processing")
|
260 |
return image_som, str(parsed_content_list)
|
261 |
except Exception as e:
|
262 |
+
logger.info('error in process')
|
263 |
traceback.print_exc()
|
264 |
return image_input, 'error in process'
|
265 |
|
266 |
+
logger.info("Starting App.")
|
267 |
with gr.Blocks() as demo:
|
268 |
gr.Markdown(MARKDOWN)
|
269 |
with gr.Row():
|