Spaces:
Runtime error
Runtime error
aldan.creo
commited on
Commit
·
8f86068
0
Parent(s):
First Commit
Browse files- .gitignore +6 -0
- app.py +87 -0
- utils.py +13 -0
.gitignore
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__pycache__
|
2 |
+
.env
|
3 |
+
*.png
|
4 |
+
*.csv
|
5 |
+
*.jpeg
|
6 |
+
*.jpg
|
app.py
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from utils import add_result
|
3 |
+
#import dotenv
|
4 |
+
|
5 |
+
HF_TOKEN = ''
|
6 |
+
|
7 |
+
|
8 |
+
def submit_result(user_answer):
|
9 |
+
add_result({"user_answer": user_answer})
|
10 |
+
return
|
11 |
+
|
12 |
+
|
13 |
+
def get_user_prompt():
|
14 |
+
return {
|
15 |
+
"images": [
|
16 |
+
"images/1.jpeg",
|
17 |
+
"images/1.jpeg",
|
18 |
+
"images/1.jpeg",
|
19 |
+
],
|
20 |
+
"labels": [
|
21 |
+
"A pencil",
|
22 |
+
"A camera",
|
23 |
+
"A sheet of paper",
|
24 |
+
],
|
25 |
+
}
|
26 |
+
|
27 |
+
hf_writer = gr.HuggingFaceDatasetSaver(hf_token=HF_TOKEN, dataset_name='maker-faire-bot', private=True)
|
28 |
+
csv_writer = gr.CSVLogger()
|
29 |
+
|
30 |
+
theme = gr.themes.Default(primary_hue="cyan", secondary_hue="fuchsia")
|
31 |
+
|
32 |
+
with gr.Blocks(theme=theme) as demo:
|
33 |
+
with gr.Row() as header:
|
34 |
+
gr.Image(
|
35 |
+
"maker-faire-logo.png",
|
36 |
+
show_download_button=False,
|
37 |
+
show_label=False,
|
38 |
+
show_share_button=False,
|
39 |
+
container=False,
|
40 |
+
#height=100,
|
41 |
+
scale=0.2
|
42 |
+
)
|
43 |
+
gr.Markdown(
|
44 |
+
"""
|
45 |
+
# Maker Faire Bot
|
46 |
+
""",
|
47 |
+
visible=False
|
48 |
+
)
|
49 |
+
|
50 |
+
# user_prompt = gr.State(get_user_prompt())
|
51 |
+
user_prompt = get_user_prompt()
|
52 |
+
|
53 |
+
gr.Markdown("""# Think about these objects...""")
|
54 |
+
gr.Markdown("""We want to teach the Maker Faire Bot some creativity. Help us get ideas on what you'd build!""")
|
55 |
+
with gr.Row(variant="panel") as row:
|
56 |
+
for i in range(len(user_prompt["images"])):
|
57 |
+
print(i)
|
58 |
+
with gr.Column(variant="default") as col:
|
59 |
+
gr.Image(
|
60 |
+
user_prompt["images"][i],
|
61 |
+
label=user_prompt["labels"][i],
|
62 |
+
interactive=False,
|
63 |
+
show_download_button=False,
|
64 |
+
show_share_button=False,
|
65 |
+
)
|
66 |
+
# gr.Text(user_prompt['labels'][i])
|
67 |
+
|
68 |
+
user_answer = gr.Textbox(
|
69 |
+
autofocus=True,
|
70 |
+
placeholder="(example): An electronic guitar",
|
71 |
+
label="What would you build?",
|
72 |
+
)
|
73 |
+
user_answer = gr.TextArea(
|
74 |
+
autofocus=True, label="How would you build it?", placeholder="""I'd use the camera to detect when the user touches the strings and make a sound using the loudspeakers when that happens."""
|
75 |
+
)
|
76 |
+
|
77 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
78 |
+
#submit_btn.click()
|
79 |
+
|
80 |
+
gr.Markdown(
|
81 |
+
"""
|
82 |
+
This is an experimental project. Your data is anonymous and will be used to train an AI model. By using this tool, you agree to our [policy](https://makerfaire.com/privacy).
|
83 |
+
"""
|
84 |
+
)
|
85 |
+
|
86 |
+
if __name__ == "__main__":
|
87 |
+
demo.launch()
|
utils.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict
|
2 |
+
import logging
|
3 |
+
|
4 |
+
logger = logging.getLogger(__file__)
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
def add_result(result: Dict):
|
9 |
+
"""
|
10 |
+
Adds the result to the dataset and stores it to disk
|
11 |
+
"""
|
12 |
+
logger.info(f"Logging result: {result}")
|
13 |
+
return
|