Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -75,12 +75,13 @@ def detect_objects(model_name,url_input,image_input,threshold):
|
|
75 |
|
76 |
return viz_img
|
77 |
|
|
|
78 |
def detect_objects2(model_name,url_input,image_input,threshold,type2):
|
79 |
|
80 |
#Extract model and feature extractor
|
81 |
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
|
82 |
|
83 |
-
|
84 |
|
85 |
model = DetrForObjectDetection.from_pretrained(model_name)
|
86 |
|
@@ -119,11 +120,15 @@ def detect_objects2(model_name,url_input,image_input,threshold,type2):
|
|
119 |
total_text+="Measuring Tape (Horizontal) for measuring Width is NOT Detected \n"
|
120 |
if type2=="Trench Width Measurement":
|
121 |
xxresult=1
|
|
|
|
|
|
|
|
|
122 |
if xxresult==0:
|
123 |
text2 = "The photo is ACCEPTED"
|
124 |
else:
|
125 |
text2 = "The photo is NOT ACCEPTED"
|
126 |
-
return
|
127 |
|
128 |
def set_example_image(example: list) -> dict:
|
129 |
return gr.Image.update(value=example[0])
|
@@ -180,8 +185,8 @@ with demo:
|
|
180 |
name = gr.Textbox(label="Final Result")
|
181 |
output = gr.Textbox(label="Reason for the results")
|
182 |
greet_btn = gr.Button("Results")
|
183 |
-
greet_btn.click(fn=detect_objects2
|
184 |
-
name.change(fn=
|
185 |
|
186 |
|
187 |
|
|
|
75 |
|
76 |
return viz_img
|
77 |
|
78 |
+
xxresult=0
|
79 |
def detect_objects2(model_name,url_input,image_input,threshold,type2):
|
80 |
|
81 |
#Extract model and feature extractor
|
82 |
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
|
83 |
|
84 |
+
|
85 |
|
86 |
model = DetrForObjectDetection.from_pretrained(model_name)
|
87 |
|
|
|
120 |
total_text+="Measuring Tape (Horizontal) for measuring Width is NOT Detected \n"
|
121 |
if type2=="Trench Width Measurement":
|
122 |
xxresult=1
|
123 |
+
|
124 |
+
return total_text
|
125 |
+
|
126 |
+
def tott():
|
127 |
if xxresult==0:
|
128 |
text2 = "The photo is ACCEPTED"
|
129 |
else:
|
130 |
text2 = "The photo is NOT ACCEPTED"
|
131 |
+
return text2
|
132 |
|
133 |
def set_example_image(example: list) -> dict:
|
134 |
return gr.Image.update(value=example[0])
|
|
|
185 |
name = gr.Textbox(label="Final Result")
|
186 |
output = gr.Textbox(label="Reason for the results")
|
187 |
greet_btn = gr.Button("Results")
|
188 |
+
greet_btn.click(fn=detect_objects2, inputs=[options,img_input,img_input,slider_input,options2], outputs=output, queue=True)
|
189 |
+
name.change(fn=tott, inputs=[], outputs=name, queue=True)
|
190 |
|
191 |
|
192 |
|