Spaces:
Running
Running
Commit
·
720bf8c
1
Parent(s):
e8486fd
rollback
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
import matplotlib.pyplot as plt
|
4 |
|
5 |
# def abnormal(image):
|
6 |
# if (image is None) or (image == ''):
|
@@ -36,16 +35,15 @@ import matplotlib.pyplot as plt
|
|
36 |
|
37 |
def abnormal_stream(image):
|
38 |
try:
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
)
|
49 |
|
50 |
if r.status_code != 200:
|
51 |
return {'확인불가': 1.0, r.status_code: 0.0, r.text: 0.0}
|
@@ -65,7 +63,7 @@ def abnormal_stream(image):
|
|
65 |
with gr.Blocks() as demo:
|
66 |
with gr.Row():
|
67 |
with gr.Column():
|
68 |
-
input_img = gr.Image(sources=["webcam"])
|
69 |
with gr.Column():
|
70 |
output_label = gr.Label()
|
71 |
dep = input_img.stream(abnormal_stream, [input_img], [output_label])
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
|
|
3 |
|
4 |
# def abnormal(image):
|
5 |
# if (image is None) or (image == ''):
|
|
|
35 |
|
36 |
def abnormal_stream(image):
|
37 |
try:
|
38 |
+
with open(image, 'rb') as f:
|
39 |
+
r = requests.post(
|
40 |
+
'https://6a051cv20250210-prediction.cognitiveservices.azure.com/customvision/v3.0/Prediction/29f565b7-4710-47a5-8a47-723048ff7ec9/classify/iterations/Iteration2/image',
|
41 |
+
headers={
|
42 |
+
'Prediction-Key': '8uyKSiqRNbG2JLdMjI8AeOzADtORP3jRh5klqQr0JsJrBBt7x7iPJQQJ99BBACYeBjFXJ3w3AAAIACOGHg4K',
|
43 |
+
'Content-Type': 'application/octet-stream',
|
44 |
+
},
|
45 |
+
data=f.read(),
|
46 |
+
)
|
|
|
47 |
|
48 |
if r.status_code != 200:
|
49 |
return {'확인불가': 1.0, r.status_code: 0.0, r.text: 0.0}
|
|
|
63 |
with gr.Blocks() as demo:
|
64 |
with gr.Row():
|
65 |
with gr.Column():
|
66 |
+
input_img = gr.Image(sources=["webcam"], type="filepath")
|
67 |
with gr.Column():
|
68 |
output_label = gr.Label()
|
69 |
dep = input_img.stream(abnormal_stream, [input_img], [output_label])
|