Spaces:
Runtime error
Runtime error
Trying again
Browse files- .gitignore +2 -1
- app.py +8 -16
.gitignore
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
.ipynb_checkpoints
|
2 |
flagged
|
3 |
telecom_object_detection.ipynb
|
4 |
-
.env
|
|
|
|
1 |
.ipynb_checkpoints
|
2 |
flagged
|
3 |
telecom_object_detection.ipynb
|
4 |
+
.env
|
5 |
+
*.png
|
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: telecom_object_detection.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
-
__all__ = ['title', 'css', 'urls', 'imgs', 'img_samples', 'fig2img', 'custom_vision_detect_objects', '
|
5 |
-
'
|
6 |
|
7 |
# %% telecom_object_detection.ipynb 2
|
8 |
import gradio as gr
|
@@ -109,18 +109,12 @@ imgs = [path.as_posix() for path in sorted(Path('images').rglob('*.jpg'))]
|
|
109 |
img_samples = [[path.as_posix()] for path in sorted(Path('images').rglob('*.jpg'))]
|
110 |
|
111 |
# %% telecom_object_detection.ipynb 17
|
112 |
-
def flip_text(): pass
|
113 |
-
def flip_image(): pass
|
114 |
def set_example_url(example: list) -> dict:
|
115 |
return gr.Textbox.update(value=example[0])
|
116 |
|
117 |
def set_example_image(example: list) -> dict:
|
118 |
-
#print(example)
|
119 |
-
#print(gr.Image.update(value=example[0]))
|
120 |
return gr.Image.update(value=example[0])
|
121 |
|
122 |
-
#def detect_objects(url_input, image_input):
|
123 |
-
|
124 |
def detect_objects(image_input:Image):
|
125 |
#if validators.url(url_input):
|
126 |
# image = Image.open(requests.get(url_input, stream=True).raw)
|
@@ -131,21 +125,19 @@ def detect_objects(image_input:Image):
|
|
131 |
w, h = image_input.size
|
132 |
|
133 |
if max(w, h) > 1_200:
|
134 |
-
#factor = int(max(w, h) / 1_200)
|
135 |
-
#image_input = image_input.reduce(factor)
|
136 |
factor = 1_200 / max(w, h)
|
|
|
137 |
size = (int(w*factor), int(h*factor))
|
138 |
image_input = image_input.resize(size, resample=Image.Resampling.BILINEAR)
|
139 |
|
140 |
-
resized_image_path = "input_object_detection.
|
141 |
-
|
142 |
|
143 |
-
#return
|
144 |
-
return image_input
|
145 |
#return custom_vision_detect_objects(Path(filename[0]))
|
146 |
-
|
147 |
|
148 |
-
# %% telecom_object_detection.ipynb
|
149 |
with gr.Blocks(css=css) as demo:
|
150 |
|
151 |
gr.Markdown(title)
|
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: telecom_object_detection.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
+
__all__ = ['title', 'css', 'urls', 'imgs', 'img_samples', 'fig2img', 'custom_vision_detect_objects', 'set_example_url',
|
5 |
+
'set_example_image', 'detect_objects']
|
6 |
|
7 |
# %% telecom_object_detection.ipynb 2
|
8 |
import gradio as gr
|
|
|
109 |
img_samples = [[path.as_posix()] for path in sorted(Path('images').rglob('*.jpg'))]
|
110 |
|
111 |
# %% telecom_object_detection.ipynb 17
|
|
|
|
|
112 |
def set_example_url(example: list) -> dict:
|
113 |
return gr.Textbox.update(value=example[0])
|
114 |
|
115 |
def set_example_image(example: list) -> dict:
|
|
|
|
|
116 |
return gr.Image.update(value=example[0])
|
117 |
|
|
|
|
|
118 |
def detect_objects(image_input:Image):
|
119 |
#if validators.url(url_input):
|
120 |
# image = Image.open(requests.get(url_input, stream=True).raw)
|
|
|
125 |
w, h = image_input.size
|
126 |
|
127 |
if max(w, h) > 1_200:
|
|
|
|
|
128 |
factor = 1_200 / max(w, h)
|
129 |
+
factor = 1
|
130 |
size = (int(w*factor), int(h*factor))
|
131 |
image_input = image_input.resize(size, resample=Image.Resampling.BILINEAR)
|
132 |
|
133 |
+
resized_image_path = "input_object_detection.jpg"
|
134 |
+
image_input.save(resized_image_path)
|
135 |
|
136 |
+
#return image_input
|
|
|
137 |
#return custom_vision_detect_objects(Path(filename[0]))
|
138 |
+
return custom_vision_detect_objects(resized_image_path)
|
139 |
|
140 |
+
# %% telecom_object_detection.ipynb 19
|
141 |
with gr.Blocks(css=css) as demo:
|
142 |
|
143 |
gr.Markdown(title)
|