aldan.creo commited on
Commit
a5ef230
·
1 Parent(s): cb93205
Files changed (3) hide show
  1. .gitignore +2 -1
  2. README.md +10 -0
  3. app.py +25 -14
.gitignore CHANGED
@@ -3,4 +3,5 @@ __pycache__
3
  *.png
4
  *.csv
5
  *.jpeg
6
- *.jpg
 
 
3
  *.png
4
  *.csv
5
  *.jpeg
6
+ *.jpg
7
+ user_data*
README.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Maker Faire Bot
3
+ emoji: 👀
4
+ colorFrom: pink
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 4.20.1
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
app.py CHANGED
@@ -4,19 +4,12 @@ import os
4
  import gradio as gr
5
  from dotenv import load_dotenv
6
 
7
- from utils import add_result
8
-
9
  logger = logging.getLogger(__name__)
10
  logger.setLevel(logging.DEBUG)
11
 
12
  load_dotenv()
13
 
14
 
15
- def submit_result(user_answer):
16
- add_result({"user_answer": user_answer})
17
- return
18
-
19
-
20
  def get_user_prompt():
21
  return {
22
  "images": [
@@ -25,9 +18,9 @@ def get_user_prompt():
25
  "images/1.jpeg",
26
  ],
27
  "labels": [
28
- "A pencil",
29
  "A camera",
30
- "A sheet of paper",
31
  ],
32
  }
33
 
@@ -76,24 +69,42 @@ with gr.Blocks(theme=theme) as demo:
76
 
77
  user_answer_object = gr.Textbox(
78
  autofocus=True,
79
- placeholder="(example): An electronic guitar",
80
  label="What would you build?",
81
  )
82
  user_answer_explanation = gr.TextArea(
83
  autofocus=True,
84
  label="How would you build it?",
85
- placeholder="""I'd use the camera to detect when the user touches the strings and make a sound using the loudspeakers when that happens.""",
 
 
 
 
 
 
 
86
  )
87
 
88
- csv_writer.setup(components=[user_prompt, user_answer_object, user_answer_explanation], flagging_dir="flagged_data_csv")
89
- hf_writer.setup(components=[user_prompt, user_answer_object, user_answer_explanation], flagging_dir="flagged_data_hf")
 
 
 
 
 
 
90
 
91
  submit_btn = gr.Button("Submit", variant="primary")
 
92
  def log_results(prompt, object, explanation):
93
  csv_writer.flag([prompt, object, explanation])
94
  hf_writer.flag([prompt, object, explanation])
95
 
96
- submit_btn.click(log_results, inputs=[user_prompt, user_answer_object, user_answer_explanation], preprocess=False)
 
 
 
 
97
 
98
  gr.Markdown(
99
  """
 
4
  import gradio as gr
5
  from dotenv import load_dotenv
6
 
 
 
7
  logger = logging.getLogger(__name__)
8
  logger.setLevel(logging.DEBUG)
9
 
10
  load_dotenv()
11
 
12
 
 
 
 
 
 
13
  def get_user_prompt():
14
  return {
15
  "images": [
 
18
  "images/1.jpeg",
19
  ],
20
  "labels": [
21
+ "A roll of string",
22
  "A camera",
23
+ "A loudspeaker",
24
  ],
25
  }
26
 
 
69
 
70
  user_answer_object = gr.Textbox(
71
  autofocus=True,
72
+ placeholder="(example): An digital electronic guitar",
73
  label="What would you build?",
74
  )
75
  user_answer_explanation = gr.TextArea(
76
  autofocus=True,
77
  label="How would you build it?",
78
+ # The example uses a roll of string, a camera, and a loudspeaker to build an electronic guitar.
79
+ placeholder="""To build an electronic guitar, I would:
80
+ 1. Use the roll of string to create the strings of the guitar.
81
+ 2. Use the camera to capture a live video of the hand movements. That way, I can use an AI model to predict the chords.
82
+ 3. Using a computer vision model, identify where the fingers are placed on the strings.
83
+ 4. Calculate the sounds that the loudspeaker should produce based on the finger placements.
84
+ 5. Play the sound through the loudspeaker.
85
+ """,
86
  )
87
 
88
+ csv_writer.setup(
89
+ components=[user_prompt, user_answer_object, user_answer_explanation],
90
+ flagging_dir="user_data_csv",
91
+ )
92
+ hf_writer.setup(
93
+ components=[user_prompt, user_answer_object, user_answer_explanation],
94
+ flagging_dir="user_data_hf",
95
+ )
96
 
97
  submit_btn = gr.Button("Submit", variant="primary")
98
+
99
  def log_results(prompt, object, explanation):
100
  csv_writer.flag([prompt, object, explanation])
101
  hf_writer.flag([prompt, object, explanation])
102
 
103
+ submit_btn.click(
104
+ log_results,
105
+ inputs=[user_prompt, user_answer_object, user_answer_explanation],
106
+ preprocess=False,
107
+ )
108
 
109
  gr.Markdown(
110
  """