hyunjunian commited on
Commit
a0a091e
·
1 Parent(s): bd276da

to streaming

Browse files
app.py CHANGED
@@ -1,9 +1,42 @@
1
  import gradio as gr
2
  import requests
3
 
4
- def abnormal(image):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  if (image is None) or (image == ''):
6
  return {'이미지가 제공되지 않았습니다.': 1.0}
 
7
  try:
8
  with open(image, 'rb') as f:
9
  r = requests.post(
@@ -30,5 +63,12 @@ def abnormal(image):
30
  except Exception as e:
31
  return {[str(e)]: 1.0}
32
 
33
- demo = gr.Interface(fn=abnormal, inputs=gr.Image(label="Input Image Component", type="filepath"), outputs="label")
 
 
 
 
 
 
 
34
  demo.launch()
 
1
  import gradio as gr
2
  import requests
3
 
4
+ # def abnormal(image):
5
+ # if (image is None) or (image == ''):
6
+ # return {'이미지가 제공되지 않았습니다.': 1.0}
7
+
8
+ # try:
9
+ # with open(image, 'rb') as f:
10
+ # r = requests.post(
11
+ # 'https://6a051cv20250210-prediction.cognitiveservices.azure.com/customvision/v3.0/Prediction/29f565b7-4710-47a5-8a47-723048ff7ec9/classify/iterations/Iteration2/image',
12
+ # headers={
13
+ # 'Prediction-Key': '8uyKSiqRNbG2JLdMjI8AeOzADtORP3jRh5klqQr0JsJrBBt7x7iPJQQJ99BBACYeBjFXJ3w3AAAIACOGHg4K',
14
+ # 'Content-Type': 'application/octet-stream',
15
+ # },
16
+ # data=f.read(),
17
+ # )
18
+
19
+ # if r.status_code != 200:
20
+ # return {'확인불가': 1.0}
21
+
22
+ # output_dict = {}
23
+
24
+ # for item in r.json()['predictions']:
25
+ # tag_name = item['tagName']
26
+ # probability = item['probability']
27
+ # output_dict[tag_name] = probability
28
+
29
+ # return output_dict
30
+
31
+ # except Exception as e:
32
+ # return {[str(e)]: 1.0}
33
+
34
+ # demo = gr.Interface(abnormal, gr.Image(label="Input Image Component", type="filepath", sources=["webcam"]), "label")
35
+
36
+ def abnormal_stream(image):
37
  if (image is None) or (image == ''):
38
  return {'이미지가 제공되지 않았습니다.': 1.0}
39
+
40
  try:
41
  with open(image, 'rb') as f:
42
  r = requests.post(
 
63
  except Exception as e:
64
  return {[str(e)]: 1.0}
65
 
66
+ with gr.Blocks() as demo:
67
+ with gr.Row():
68
+ with gr.Column():
69
+ input_img = gr.Image(sources=["webcam"], type="filepath")
70
+ with gr.Column():
71
+ output_img = gr.Label()
72
+ dep = input_img.stream(abnormal_stream, [input_img], [output_img], every=1)
73
+
74
  demo.launch()
flagged/Input Image Component/51dc4ea78146ecbd3ec2/wine.png ADDED
flagged/log.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Input Image Component,output,flag,username,timestamp
2
+ flagged/Input Image Component/51dc4ea78146ecbd3ec2/wine.png,"{""label"": ""\ubab8 \ubabb \uac00\ub204\uae30"", ""confidences"": [{""label"": ""\ubab8 \ubabb \uac00\ub204\uae30"", ""confidence"": 0.51231885}, {""label"": ""\ubaa9\ub9cc\uc9c0\ub2e4"", ""confidence"": 0.29413196}, {""label"": ""\uc5b4\uae68 \ub450\ub4dc\ub9ac\uae30"", ""confidence"": 0.09920414}, {""label"": ""\ub208\ube44\ube44\uae30"", ""confidence"": 0.05283867}, {""label"": ""\uc6b4\uc804\ud558\ub2e4"", ""confidence"": 0.022258094}, {""label"": ""\ud558\ud488"", ""confidence"": 0.015104012}, {""label"": ""\ubea8\ub54c\ub9ac\uae30"", ""confidence"": 0.002993021}, {""label"": ""\uafb8\ubc85\uafb8\ubc85\uc878\ub2e4"", ""confidence"": 0.001151227}]}",,,2025-02-20 14:54:55.603445