eeshawn commited on
Commit
06e6bb3
1 Parent(s): 0a4c6d9

app.py revert changes

Browse files
Files changed (1) hide show
  1. app.py +5 -25
app.py CHANGED
@@ -3,15 +3,11 @@ import torch
3
  from ultralyticsplus import YOLO, render_result
4
  import os
5
 
6
- HF_TOKEN = os.getenv('HF_TOKEN')
7
-
8
  yolo_model = YOLO('eeshawn11/naruto_hand_seal_detection')
9
  yolo_model.overrides['max_det'] = 10
10
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
11
  yolo_model.to(device)
12
 
13
- !wget -q https://github.com/gradio-app/gradio/raw/main/demo/blocks_inputs/lion.jpg
14
-
15
  def seal_detection(
16
  image,
17
  conf_threshold,
@@ -37,8 +33,6 @@ def clear():
37
  conf_update = gr.Slider.update(value=0.5)
38
  return image_update, conf_update, image_update
39
 
40
- callback = gr.HuggingFaceDatasetJSONSaver(hf_token=HF_TOKEN, dataset_name="crowdsourced_hand_seals", private=True)
41
-
42
  with gr.Blocks() as demo:
43
  gr.Markdown("# Naruto Hand Seal Detection with YOLOv8")
44
  with gr.Accordion("README", open=False):
@@ -51,7 +45,11 @@ with gr.Blocks() as demo:
51
  Hand seals are an integral part of the Naruto universe, used by characters to activate powerful techniques. There are twelve basic seals, each named after an animal in the Chinese Zodiac, and different sequences of hand seals are required for different techniques.
52
 
53
  As a fan of the series, I knew that accurately detecting and classifying hand seals would be a difficult but rewarding challenge, and I was excited to tackle it using my expertise in machine learning and computer vision. One key challenge to overcome would be the lack of a good dataset of labelled images for training, so I had to develop my own. Besides capturing images of myself performing the seals, I augmented my dataset with YouTube screenshots consisting of both real persons and anime characters performing the seals.
54
-
 
 
 
 
55
  ### Problem Statement
56
 
57
  The challenge was to develop a model that could accurately identify the hand seal being performed.
@@ -62,28 +60,13 @@ with gr.Blocks() as demo:
62
 
63
  with gr.Row():
64
  with gr.Column():
65
- # inputs = [
66
  image = gr.Image(source="upload", type="pil", label="Image Upload", interactive=True),
67
  slider = gr.Slider(minimum=0.05, maximum=1.0, value=0.5, step=0.05, label="Confidence Threshold"),
68
- # ]
69
  with gr.Row():
70
  clear_form = gr.Button("Reset")
71
  submit = gr.Button("Predict")
72
  with gr.Column():
73
  outputs = gr.Image(type="filepath", label="Output Image", interactive=False)
74
- # flag = gr.Button("Flag")
75
-
76
- with gr.Row():
77
- gr.Examples(
78
- examples=[os.path.join(os.path.dirname(__file__), "lion.jpg")],
79
- inputs=image,
80
- outputs=outputs,
81
- fn=seal_detection,
82
- run_on_click=True,
83
- # preprocess=False,
84
- # postprocess=False,
85
- cache_examples=True,
86
- )
87
 
88
  gr.Markdown(
89
  """
@@ -91,12 +74,9 @@ with gr.Blocks() as demo:
91
  Happy to connect on <a href="https://www.linkedin.com/in/shawn-sing/" target="_blank">LinkedIn</a> or visit my <a href="https://github.com/eeshawn11/" target="_blank">GitHub</a> to check out my other projects.
92
  """
93
  )
94
-
95
- # callback.setup([image, slider, outputs], "crowdsourced_hand_seals")
96
 
97
  clear_form.click(fn=clear, inputs=None, outputs=[image[0], slider[0], outputs], show_progress=False)
98
  submit.click(fn=seal_detection, inputs=[image[0], slider[0]], outputs=outputs)
99
- # flag.click(lambda *args: callback.flag([image[0], slider[0], outputs]), inputs=[image[0], slider[0], outputs], outputs=None, preprocess=False)
100
 
101
  if __name__ == "__main__":
102
  demo.queue(api_open=False, max_size=10)
 
3
  from ultralyticsplus import YOLO, render_result
4
  import os
5
 
 
 
6
  yolo_model = YOLO('eeshawn11/naruto_hand_seal_detection')
7
  yolo_model.overrides['max_det'] = 10
8
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
9
  yolo_model.to(device)
10
 
 
 
11
  def seal_detection(
12
  image,
13
  conf_threshold,
 
33
  conf_update = gr.Slider.update(value=0.5)
34
  return image_update, conf_update, image_update
35
 
 
 
36
  with gr.Blocks() as demo:
37
  gr.Markdown("# Naruto Hand Seal Detection with YOLOv8")
38
  with gr.Accordion("README", open=False):
 
45
  Hand seals are an integral part of the Naruto universe, used by characters to activate powerful techniques. There are twelve basic seals, each named after an animal in the Chinese Zodiac, and different sequences of hand seals are required for different techniques.
46
 
47
  As a fan of the series, I knew that accurately detecting and classifying hand seals would be a difficult but rewarding challenge, and I was excited to tackle it using my expertise in machine learning and computer vision. One key challenge to overcome would be the lack of a good dataset of labelled images for training, so I had to develop my own. Besides capturing images of myself performing the seals, I augmented my dataset with YouTube screenshots consisting of both real persons and anime characters performing the seals.
48
+
49
+ <p style="text-align:center">
50
+ <img src"https://huggingface.co/spaces/eeshawn11/naruto_hand_seals/blob/main/assets/Naruto_Hand_Seals_by_Megan.gif">
51
+ </p>
52
+
53
  ### Problem Statement
54
 
55
  The challenge was to develop a model that could accurately identify the hand seal being performed.
 
60
 
61
  with gr.Row():
62
  with gr.Column():
 
63
  image = gr.Image(source="upload", type="pil", label="Image Upload", interactive=True),
64
  slider = gr.Slider(minimum=0.05, maximum=1.0, value=0.5, step=0.05, label="Confidence Threshold"),
 
65
  with gr.Row():
66
  clear_form = gr.Button("Reset")
67
  submit = gr.Button("Predict")
68
  with gr.Column():
69
  outputs = gr.Image(type="filepath", label="Output Image", interactive=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  gr.Markdown(
72
  """
 
74
  Happy to connect on <a href="https://www.linkedin.com/in/shawn-sing/" target="_blank">LinkedIn</a> or visit my <a href="https://github.com/eeshawn11/" target="_blank">GitHub</a> to check out my other projects.
75
  """
76
  )
 
 
77
 
78
  clear_form.click(fn=clear, inputs=None, outputs=[image[0], slider[0], outputs], show_progress=False)
79
  submit.click(fn=seal_detection, inputs=[image[0], slider[0]], outputs=outputs)
 
80
 
81
  if __name__ == "__main__":
82
  demo.queue(api_open=False, max_size=10)