Spaces:
Runtime error
Runtime error
import gradio as gr | |
from utils import add_result | |
#import dotenv | |
HF_TOKEN = '' | |
def submit_result(user_answer): | |
add_result({"user_answer": user_answer}) | |
return | |
def get_user_prompt(): | |
return { | |
"images": [ | |
"images/1.jpeg", | |
"images/1.jpeg", | |
"images/1.jpeg", | |
], | |
"labels": [ | |
"A pencil", | |
"A camera", | |
"A sheet of paper", | |
], | |
} | |
hf_writer = gr.HuggingFaceDatasetSaver(hf_token=HF_TOKEN, dataset_name='maker-faire-bot', private=True) | |
csv_writer = gr.CSVLogger() | |
theme = gr.themes.Default(primary_hue="cyan", secondary_hue="fuchsia") | |
with gr.Blocks(theme=theme) as demo: | |
with gr.Row() as header: | |
gr.Image( | |
"maker-faire-logo.png", | |
show_download_button=False, | |
show_label=False, | |
show_share_button=False, | |
container=False, | |
#height=100, | |
scale=0.2 | |
) | |
gr.Markdown( | |
""" | |
# Maker Faire Bot | |
""", | |
visible=False | |
) | |
# user_prompt = gr.State(get_user_prompt()) | |
user_prompt = get_user_prompt() | |
gr.Markdown("""# Think about these objects...""") | |
gr.Markdown("""We want to teach the Maker Faire Bot some creativity. Help us get ideas on what you'd build!""") | |
with gr.Row(variant="panel") as row: | |
for i in range(len(user_prompt["images"])): | |
print(i) | |
with gr.Column(variant="default") as col: | |
gr.Image( | |
user_prompt["images"][i], | |
label=user_prompt["labels"][i], | |
interactive=False, | |
show_download_button=False, | |
show_share_button=False, | |
) | |
# gr.Text(user_prompt['labels'][i]) | |
user_answer = gr.Textbox( | |
autofocus=True, | |
placeholder="(example): An electronic guitar", | |
label="What would you build?", | |
) | |
user_answer = gr.TextArea( | |
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.""" | |
) | |
submit_btn = gr.Button("Submit", variant="primary") | |
#submit_btn.click() | |
gr.Markdown( | |
""" | |
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). | |
""" | |
) | |
if __name__ == "__main__": | |
demo.launch() | |