Spaces:
Runtime error
Runtime error
Jyothish CHANDRASENAN
commited on
Commit
·
c28cea5
1
Parent(s):
5890cac
Update app.py
Browse files
app.py
CHANGED
@@ -134,8 +134,8 @@ def postprocessor(prediction, orig_img):
|
|
134 |
distance = distanceCalculate(points[0], points[1])
|
135 |
midpoints = midpoint(points[0], points[1])
|
136 |
result_image = cv2.line(result_image, points[0], points[1], (0,0,255), 1)
|
137 |
-
result_image = cv2.putText(result_image,str(distance), (midpoints[0],midpoints[0]+10), cv2.FONT_HERSHEY_SIMPLEX, 0.40, (0,0,255), 1, cv2.LINE_AA)
|
138 |
-
return result_image
|
139 |
|
140 |
def distanceCalculate(p1, p2):
|
141 |
"""p1 and p2 in format (x1,y1) and (x2,y2) tuples"""
|
@@ -171,14 +171,15 @@ def predict(img):
|
|
171 |
preprocessed_img, orig_img = preprocessor(raw_img)
|
172 |
# infer
|
173 |
prediction = infer(preprocessed_img)
|
174 |
-
keypoints_map = postprocessor(prediction, orig_img)
|
175 |
# cv2.imwrite("keypoints_map.png", keypoints_map[:,:,::-1])
|
176 |
-
|
|
|
177 |
|
178 |
|
179 |
gr.Interface(fn=predict,
|
180 |
inputs=[gr.Image(shape=(224,224),type="filepath")],
|
181 |
-
outputs=[gr.Image(shape=(224,224))],
|
182 |
css="footer {visibility: hidden} body}, .gradio-container {background-color: white}",
|
183 |
title="Automi Demo",
|
184 |
examples=["001.png","002.png","003.png","004.png","005.png"]).launch(share=False)
|
|
|
134 |
distance = distanceCalculate(points[0], points[1])
|
135 |
midpoints = midpoint(points[0], points[1])
|
136 |
result_image = cv2.line(result_image, points[0], points[1], (0,0,255), 1)
|
137 |
+
# result_image = cv2.putText(result_image,str(distance), (midpoints[0],midpoints[0]+10), cv2.FONT_HERSHEY_SIMPLEX, 0.40, (0,0,255), 1, cv2.LINE_AA)
|
138 |
+
return result_image, distance
|
139 |
|
140 |
def distanceCalculate(p1, p2):
|
141 |
"""p1 and p2 in format (x1,y1) and (x2,y2) tuples"""
|
|
|
171 |
preprocessed_img, orig_img = preprocessor(raw_img)
|
172 |
# infer
|
173 |
prediction = infer(preprocessed_img)
|
174 |
+
keypoints_map, distance_keypoints = postprocessor(prediction, orig_img)
|
175 |
# cv2.imwrite("keypoints_map.png", keypoints_map[:,:,::-1])
|
176 |
+
display_text = "The distance between two key points A and B is {distance_keypoints} pixel units"
|
177 |
+
return keypoints_map, display_text
|
178 |
|
179 |
|
180 |
gr.Interface(fn=predict,
|
181 |
inputs=[gr.Image(shape=(224,224),type="filepath")],
|
182 |
+
outputs=[gr.Image(shape=(224,224)), "text"],
|
183 |
css="footer {visibility: hidden} body}, .gradio-container {background-color: white}",
|
184 |
title="Automi Demo",
|
185 |
examples=["001.png","002.png","003.png","004.png","005.png"]).launch(share=False)
|