Spaces:
Sleeping
Sleeping
keerthan-innova8s
commited on
Commit
•
136da31
1
Parent(s):
112210a
Update app.py
Browse files
app.py
CHANGED
@@ -61,13 +61,11 @@ def draw_results(image, detections, colors_list):
|
|
61 |
rgb_color = (int(color[0]), int(color[1]), int(color[2]))
|
62 |
color_name = get_color_name(rgb_color)
|
63 |
hex_color = "#{:02x}{:02x}{:02x}".format(rgb_color[0], rgb_color[1], rgb_color[2])
|
64 |
-
|
65 |
-
global color_info
|
66 |
color_info = f"{color_name}"
|
67 |
|
68 |
cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
69 |
cv2.putText(image, color_info, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
|
70 |
-
return image
|
71 |
|
72 |
def main(image_path):
|
73 |
#model = load_model(model_path)
|
@@ -79,22 +77,22 @@ def main(image_path):
|
|
79 |
cropped_regions = crop_regions(image, detections)
|
80 |
colors_list = [get_dominant_color(region) for region in cropped_regions]
|
81 |
|
82 |
-
output_image = draw_results(image, detections, colors_list)
|
83 |
|
84 |
-
return output_image
|
85 |
|
86 |
def result(input_image):
|
87 |
input_image_path = f"{CURRENT_DIR}/input_image.jpg"
|
88 |
cv2.imwrite(input_image_path, input_image)
|
89 |
img = input_image_path
|
90 |
-
processed_img = main(img)
|
91 |
|
92 |
-
return processed_img
|
93 |
|
94 |
demo = gr.Interface(
|
95 |
fn=result,
|
96 |
inputs=gr.Image(),
|
97 |
-
outputs=[gr.Image(),gr.Text(
|
98 |
)
|
99 |
|
100 |
demo.launch()
|
|
|
61 |
rgb_color = (int(color[0]), int(color[1]), int(color[2]))
|
62 |
color_name = get_color_name(rgb_color)
|
63 |
hex_color = "#{:02x}{:02x}{:02x}".format(rgb_color[0], rgb_color[1], rgb_color[2])
|
|
|
|
|
64 |
color_info = f"{color_name}"
|
65 |
|
66 |
cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
67 |
cv2.putText(image, color_info, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
|
68 |
+
return image, color_info
|
69 |
|
70 |
def main(image_path):
|
71 |
#model = load_model(model_path)
|
|
|
77 |
cropped_regions = crop_regions(image, detections)
|
78 |
colors_list = [get_dominant_color(region) for region in cropped_regions]
|
79 |
|
80 |
+
output_image, color = draw_results(image, detections, colors_list)
|
81 |
|
82 |
+
return output_image, color
|
83 |
|
84 |
def result(input_image):
|
85 |
input_image_path = f"{CURRENT_DIR}/input_image.jpg"
|
86 |
cv2.imwrite(input_image_path, input_image)
|
87 |
img = input_image_path
|
88 |
+
processed_img, cat_color = main(img)
|
89 |
|
90 |
+
return processed_img, cat_color
|
91 |
|
92 |
demo = gr.Interface(
|
93 |
fn=result,
|
94 |
inputs=gr.Image(),
|
95 |
+
outputs=[gr.Image(),gr.Text()]
|
96 |
)
|
97 |
|
98 |
demo.launch()
|