Spaces:
Runtime error
Runtime error
blocks
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
def yolov7_inference(
|
| 8 |
image: gr.Image = None,
|
|
@@ -16,39 +17,27 @@ def yolov7_inference(
|
|
| 16 |
results = model([image], size=640)
|
| 17 |
return results.render()[0]
|
| 18 |
|
| 19 |
-
|
| 20 |
-
gr.Image(type="filepath", label="Input"),
|
| 21 |
-
gr.Slider(minimum=0.0, maximum=1.0, value=0.2, step=0.05, label="Confidence Threshold", interactive=True),
|
| 22 |
-
]
|
| 23 |
-
|
| 24 |
-
outputs = [
|
| 25 |
-
gr.Image(type="filepath"),
|
| 26 |
-
|
| 27 |
-
]
|
| 28 |
-
|
| 29 |
-
css = ".output_image {height: 40rem !important; width: 100% !important;}"
|
| 30 |
-
|
| 31 |
-
demo = gr.Interface(
|
| 32 |
-
fn=yolov7_inference,
|
| 33 |
-
inputs=inputs,
|
| 34 |
-
outputs=outputs,
|
| 35 |
-
title="The detection of jar lid defects using Yolov7",
|
| 36 |
-
description = """
|
| 37 |
-
This application is detecting damaged jar lids. Type of damages include deformations, holes or scratches. The object detection notebook can be found at <a href="https://www.kaggle.com/rrighart">Kaggle</a>
|
| 38 |
|
| 39 |
-
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
""
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
css=css,
|
| 49 |
-
cache_examples=True,
|
| 50 |
)
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
demo.
|
| 54 |
-
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
def update_value(val):
|
| 6 |
+
return f'Value is set to {val}'
|
| 7 |
|
| 8 |
def yolov7_inference(
|
| 9 |
image: gr.Image = None,
|
|
|
|
| 17 |
results = model([image], size=640)
|
| 18 |
return results.render()[0]
|
| 19 |
|
| 20 |
+
demo = gr.Blocks()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
with demo:
|
| 23 |
|
| 24 |
+
dd = gr.Interface(
|
| 25 |
+
yolov7_inference,
|
| 26 |
+
gr.Image(type="pil"),
|
| 27 |
+
"image",
|
| 28 |
+
title="The detection of jar lid defects using Yolov7",
|
| 29 |
|
| 30 |
+
examples=[
|
| 31 |
+
os.path.join(os.path.dirname(__file__), "example1.JPG"),
|
| 32 |
+
os.path.join(os.path.dirname(__file__), "example2.JPG"),
|
| 33 |
+
os.path.join(os.path.dirname(__file__), "example3.JPG"),
|
| 34 |
+
],
|
|
|
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
+
md = gr.Markdown("Confidence Threshold")
|
| 38 |
+
conf_threshold = gr.Slider(minimum=0, maximum=1, step=0.1, label='Value')
|
| 39 |
+
#inp = gr.Slider(minimum=0.0, maximum=1.0, value=0.2, step=0.05, label="Value"),
|
| 40 |
+
#inp.change(fn=yolov7_inference, inputs=inp, outputs=md)
|
| 41 |
+
conf_threshold.change(fn=update_value, inputs=conf_threshold, outputs=md)
|
| 42 |
|
| 43 |
+
demo.launch()
|
|
|
slider.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def update_value(val):
|
| 4 |
+
return f'Value is set to {val}'
|
| 5 |
+
|
| 6 |
+
demo = gr.Blocks()
|
| 7 |
+
|
| 8 |
+
with demo:
|
| 9 |
+
inp = gr.Slider(0, 100, label='Value')
|
| 10 |
+
md = gr.Markdown('Select a value')
|
| 11 |
+
|
| 12 |
+
inp.change(fn=update_value, inputs=inp, outputs=md)
|
| 13 |
+
|
| 14 |
+
demo.launch()
|