Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +35 -0
- epoch_124.pt +3 -0
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
|
3 |
+
import numpy as np
|
4 |
+
import torch
|
5 |
+
import gradio
|
6 |
+
|
7 |
+
import gradio as gr
|
8 |
+
|
9 |
+
def object_detection(image):
|
10 |
+
image = image.convert("RGB")
|
11 |
+
image = image.resize((416, 416))
|
12 |
+
image = np.array(image).transpose((2, 0, 1))
|
13 |
+
image = np.expand_dims(image, axis=0).astype(np.float32)
|
14 |
+
|
15 |
+
# Run the model
|
16 |
+
outputs = session.run([output_name], {input_name: image})
|
17 |
+
|
18 |
+
# Postprocess the prediction
|
19 |
+
prediction = outputs[0][0]
|
20 |
+
|
21 |
+
return prediction
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
with gr.Blocks() as demo:
|
27 |
+
with gr.Row():
|
28 |
+
image_input=gr.Image()
|
29 |
+
image_output=gr.Image()
|
30 |
+
image_text =gr.Text()
|
31 |
+
image_button=gr.Button('start')
|
32 |
+
|
33 |
+
image_button.click(object_detection,inputs=image_input,outputs=[image_output,image_text])
|
34 |
+
demo.close()
|
35 |
+
demo.launch(server_port=9090)
|
epoch_124.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d3e17cb882b10313c8db2c1be2cb9ee4a8e26771ba76ff81f85850a37b919dbe
|
3 |
+
size 298520114
|