Spaces:
Runtime error
Runtime error
Commit
·
004a7b2
1
Parent(s):
d62afa0
making output as text
Browse files
app.py
CHANGED
@@ -153,19 +153,19 @@ def detect_Custom(img,model,boundedImage):
|
|
153 |
|
154 |
images = [keras_ocr.tools.read(img) for img in [boundedImage]]
|
155 |
prediction_groups = pipeline.recognize(images)
|
156 |
-
|
|
|
|
|
157 |
|
158 |
-
fig, ax = plt.subplots(figsize=(10, 20))
|
159 |
-
#keras_ocr.tools.drawAnnotations(image=images[0], predictions=prediction_groups[0], ax=ax)
|
160 |
if save_txt or save_img:
|
161 |
s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else ''
|
162 |
|
163 |
print(f'Done. ({time.time() - t0:.3f}s)')
|
164 |
|
165 |
-
return Image.fromarray(im0[:,:,::-1]),
|
166 |
|
167 |
|
168 |
-
|
169 |
Custom_description="<center>Custom Training Performed on Colab <a href='https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-yolov7-object-detection-on-custom-data.ipynb?authuser=2#scrollTo=1iqOPKjr22mL' style='text-decoration: underline' target='_blank'>Link</a> </center><br> <center>Model trained with test dataset of 'aadhar-card', 'credit-card','prescription' and 'passport' </center>"
|
170 |
|
171 |
Footer = (
|
@@ -183,4 +183,4 @@ examples1=[["Image1.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image2.jpeg", "Y
|
|
183 |
Top_Title="<center>Intelligent Image to Text - IIT </center></a>"
|
184 |
|
185 |
css = ".output-image, .input-image, .image-preview {height: 300px !important}"
|
186 |
-
gr.Interface(detect_Custom,[gr.Image(type="pil"),gr.Dropdown(default="Yolo_v7_Custom_trained_By_Owais",choices=["Yolo_v7_Custom_trained_By_Owais","yolov7","yolov7-e6"]),gr.Image(type="filepath")],[gr.Image(type="pil"),
|
|
|
153 |
|
154 |
images = [keras_ocr.tools.read(img) for img in [boundedImage]]
|
155 |
prediction_groups = pipeline.recognize(images)
|
156 |
+
first=prediction_groups[0]
|
157 |
+
for text,box in first:
|
158 |
+
output_text += ' '+ text
|
159 |
|
|
|
|
|
160 |
if save_txt or save_img:
|
161 |
s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else ''
|
162 |
|
163 |
print(f'Done. ({time.time() - t0:.3f}s)')
|
164 |
|
165 |
+
return Image.fromarray(im0[:,:,::-1]), output_text
|
166 |
|
167 |
|
168 |
+
output = gr.Textbox(label="Output",elem_id="opbox")
|
169 |
Custom_description="<center>Custom Training Performed on Colab <a href='https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-yolov7-object-detection-on-custom-data.ipynb?authuser=2#scrollTo=1iqOPKjr22mL' style='text-decoration: underline' target='_blank'>Link</a> </center><br> <center>Model trained with test dataset of 'aadhar-card', 'credit-card','prescription' and 'passport' </center>"
|
170 |
|
171 |
Footer = (
|
|
|
183 |
Top_Title="<center>Intelligent Image to Text - IIT </center></a>"
|
184 |
|
185 |
css = ".output-image, .input-image, .image-preview {height: 300px !important}"
|
186 |
+
gr.Interface(detect_Custom,[gr.Image(type="pil"),gr.Dropdown(default="Yolo_v7_Custom_trained_By_Owais",choices=["Yolo_v7_Custom_trained_By_Owais","yolov7","yolov7-e6"]),gr.Image(type="filepath")],[gr.Image(type="pil"),output],css=css,title=Top_Title,examples=examples1,description=Custom_description,article=Footer,cache_examples=False).launch()
|