Spaces:
Runtime error
Runtime error
Commit
·
7754142
1
Parent(s):
0febdc1
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,26 @@ def yolov8_inference(
|
|
| 33 |
render = render_result(model=model, image=image, result=results[0])
|
| 34 |
|
| 35 |
return render
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
inputs = [
|
| 39 |
# Images
|
|
@@ -42,7 +61,7 @@ inputs = [
|
|
| 42 |
'samples/1.jpeg',
|
| 43 |
'samples/2.JPG',
|
| 44 |
],
|
| 45 |
-
inputs={'postprocess':
|
| 46 |
),
|
| 47 |
gr.inputs.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
|
| 48 |
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
|
|
|
|
| 33 |
render = render_result(model=model, image=image, result=results[0])
|
| 34 |
|
| 35 |
return render
|
| 36 |
+
|
| 37 |
+
def gr_postprocess(image):
|
| 38 |
+
"""
|
| 39 |
+
Gradio postprocess function
|
| 40 |
+
Args:
|
| 41 |
+
image: Input image
|
| 42 |
+
Returns:
|
| 43 |
+
Processed image
|
| 44 |
+
"""
|
| 45 |
+
|
| 46 |
+
# Convert the image to RGB
|
| 47 |
+
image = image.convert('RGB')
|
| 48 |
+
|
| 49 |
+
# Resize the image to the desired size
|
| 50 |
+
image = image.resize((640, 480))
|
| 51 |
+
|
| 52 |
+
# Convert the image to a numpy array
|
| 53 |
+
image = np.array(image)
|
| 54 |
+
|
| 55 |
+
return image
|
| 56 |
|
| 57 |
inputs = [
|
| 58 |
# Images
|
|
|
|
| 61 |
'samples/1.jpeg',
|
| 62 |
'samples/2.JPG',
|
| 63 |
],
|
| 64 |
+
inputs={'postprocess': gr_postprocess()},
|
| 65 |
),
|
| 66 |
gr.inputs.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
|
| 67 |
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
|