Spaces:
Runtime error
Runtime error
Commit ·
186fec0
1
Parent(s): 4fcdc4e
Upload with huggingface_hub
Browse files- README.md +5 -6
- __init__.py +0 -0
- __pycache__/__init__.cpython-39.pyc +0 -0
- __pycache__/constants.cpython-39.pyc +0 -0
- __pycache__/run.cpython-39.pyc +0 -0
- app.py +98 -0
- constants.py +71 -0
README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: indigo
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.1.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
+
title: kitchen_sink_random
|
| 4 |
+
emoji: 💩
|
| 5 |
colorFrom: indigo
|
| 6 |
+
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
+
sdk_version: 3.1.4b3
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
---
|
|
|
|
|
|
__init__.py
ADDED
|
File without changes
|
__pycache__/__init__.cpython-39.pyc
ADDED
|
Binary file (158 Bytes). View file
|
|
|
__pycache__/constants.cpython-39.pyc
ADDED
|
Binary file (1.67 kB). View file
|
|
|
__pycache__/run.cpython-39.pyc
ADDED
|
Binary file (4.93 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from datetime import datetime
|
| 3 |
+
import random
|
| 4 |
+
import string
|
| 5 |
+
import os
|
| 6 |
+
import pandas as pd
|
| 7 |
+
|
| 8 |
+
from constants import (
|
| 9 |
+
file_dir,
|
| 10 |
+
img_dir,
|
| 11 |
+
highlighted_text,
|
| 12 |
+
highlighted_text_output_2,
|
| 13 |
+
highlighted_text_output_1,
|
| 14 |
+
random_plot,
|
| 15 |
+
random_model3d,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
demo = gr.Interface(
|
| 20 |
+
lambda x: x,
|
| 21 |
+
inputs=[
|
| 22 |
+
gr.Textbox(value=lambda: datetime.now(), label="Current Time"),
|
| 23 |
+
gr.Number(value=lambda: random.random(), label="Ranom Percentage"),
|
| 24 |
+
gr.Slider(minimum=-1, maximum=1, randomize=True, label="Slider with randomize"),
|
| 25 |
+
gr.Slider(
|
| 26 |
+
minimum=0,
|
| 27 |
+
maximum=1,
|
| 28 |
+
value=lambda: random.random(),
|
| 29 |
+
label="Slider with value func",
|
| 30 |
+
),
|
| 31 |
+
gr.Checkbox(value=lambda: random.random() > 0.5, label="Random Checkbox"),
|
| 32 |
+
gr.CheckboxGroup(
|
| 33 |
+
choices=["a", "b", "c", "d"],
|
| 34 |
+
value=lambda: random.choice(["a", "b", "c", "d"]),
|
| 35 |
+
label="Random CheckboxGroup",
|
| 36 |
+
),
|
| 37 |
+
gr.Radio(
|
| 38 |
+
choices=list(string.ascii_lowercase),
|
| 39 |
+
value=lambda: random.choice(string.ascii_lowercase),
|
| 40 |
+
),
|
| 41 |
+
gr.Dropdown(
|
| 42 |
+
choices=["a", "b", "c", "d", "e"],
|
| 43 |
+
value=lambda: random.choice(["a", "b", "c"]),
|
| 44 |
+
),
|
| 45 |
+
gr.Image(
|
| 46 |
+
value=lambda: random.choice(
|
| 47 |
+
[os.path.join(img_dir, img) for img in os.listdir(img_dir)]
|
| 48 |
+
)
|
| 49 |
+
),
|
| 50 |
+
gr.Video(value=lambda: os.path.join(file_dir, "world.mp4")),
|
| 51 |
+
gr.Audio(value=lambda: os.path.join(file_dir, "cantina.wav")),
|
| 52 |
+
gr.File(
|
| 53 |
+
value=lambda: random.choice(
|
| 54 |
+
[os.path.join(file_dir, img) for img in os.listdir(file_dir)]
|
| 55 |
+
)
|
| 56 |
+
),
|
| 57 |
+
gr.Dataframe(
|
| 58 |
+
value=lambda: pd.DataFrame(
|
| 59 |
+
{"random_number_rows": range(random.randint(0, 10))}
|
| 60 |
+
)
|
| 61 |
+
),
|
| 62 |
+
gr.Timeseries(value=lambda: os.path.join(file_dir, "time.csv")),
|
| 63 |
+
gr.Variable(value=lambda: random.choice(string.ascii_lowercase)),
|
| 64 |
+
gr.Button(value=lambda: random.choice(["Run", "Go", "predict"])),
|
| 65 |
+
gr.ColorPicker(value=lambda: random.choice(["#000000", "#ff0000", "#0000FF"])),
|
| 66 |
+
gr.Label(value=lambda: random.choice(["Pedestrian", "Car", "Cyclist"])),
|
| 67 |
+
gr.HighlightedText(
|
| 68 |
+
value=lambda: random.choice(
|
| 69 |
+
[
|
| 70 |
+
{"text": highlighted_text, "entities": highlighted_text_output_1},
|
| 71 |
+
{"text": highlighted_text, "entities": highlighted_text_output_2},
|
| 72 |
+
]
|
| 73 |
+
),
|
| 74 |
+
),
|
| 75 |
+
gr.JSON(value=lambda: random.choice([{"a": 1}, {"b": 2}])),
|
| 76 |
+
gr.HTML(
|
| 77 |
+
value=lambda: random.choice(
|
| 78 |
+
[
|
| 79 |
+
'<p style="color:red;">I am red</p>',
|
| 80 |
+
'<p style="color:blue;">I am blue</p>',
|
| 81 |
+
]
|
| 82 |
+
)
|
| 83 |
+
),
|
| 84 |
+
gr.Gallery(
|
| 85 |
+
value=lambda: [os.path.join(img_dir, img) for img in os.listdir(img_dir)]
|
| 86 |
+
),
|
| 87 |
+
gr.Chatbot(
|
| 88 |
+
value=lambda: random.choice([[("hello", "hi!")], [("bye", "goodbye!")]])
|
| 89 |
+
),
|
| 90 |
+
gr.Model3D(value=random_model3d),
|
| 91 |
+
gr.Plot(value=random_plot),
|
| 92 |
+
gr.Markdown(value=lambda: f"### {random.choice(['Hello', 'Hi', 'Goodbye!'])}"),
|
| 93 |
+
],
|
| 94 |
+
outputs=None,
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
if __name__ == "__main__":
|
| 98 |
+
demo.launch()
|
constants.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import matplotlib
|
| 3 |
+
|
| 4 |
+
matplotlib.use("Agg")
|
| 5 |
+
import matplotlib.pyplot as plt
|
| 6 |
+
import random
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def random_plot():
|
| 11 |
+
start_year = 2020
|
| 12 |
+
x = np.arange(start_year, start_year + random.randint(0, 10))
|
| 13 |
+
year_count = x.shape[0]
|
| 14 |
+
plt_format = "-"
|
| 15 |
+
fig = plt.figure()
|
| 16 |
+
ax = fig.add_subplot(111)
|
| 17 |
+
series = np.arange(0, year_count, dtype=float)
|
| 18 |
+
series = series**2
|
| 19 |
+
series += np.random.rand(year_count)
|
| 20 |
+
ax.plot(x, series, plt_format)
|
| 21 |
+
return fig
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
img_dir = os.path.join(os.path.dirname(__file__), "..", "image_classifier", "images")
|
| 25 |
+
file_dir = os.path.join(os.path.dirname(__file__), "..", "kitchen_sink", "files")
|
| 26 |
+
model3d_dir = os.path.join(os.path.dirname(__file__), "..", "model3D", "files")
|
| 27 |
+
highlighted_text_output_1 = [
|
| 28 |
+
{
|
| 29 |
+
"entity": "I-LOC",
|
| 30 |
+
"score": 0.9988978,
|
| 31 |
+
"index": 2,
|
| 32 |
+
"word": "Chicago",
|
| 33 |
+
"start": 5,
|
| 34 |
+
"end": 12,
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"entity": "I-MISC",
|
| 38 |
+
"score": 0.9958592,
|
| 39 |
+
"index": 5,
|
| 40 |
+
"word": "Pakistani",
|
| 41 |
+
"start": 22,
|
| 42 |
+
"end": 31,
|
| 43 |
+
},
|
| 44 |
+
]
|
| 45 |
+
highlighted_text_output_2 = [
|
| 46 |
+
{
|
| 47 |
+
"entity": "I-LOC",
|
| 48 |
+
"score": 0.9988978,
|
| 49 |
+
"index": 2,
|
| 50 |
+
"word": "Chicago",
|
| 51 |
+
"start": 5,
|
| 52 |
+
"end": 12,
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"entity": "I-LOC",
|
| 56 |
+
"score": 0.9958592,
|
| 57 |
+
"index": 5,
|
| 58 |
+
"word": "Pakistan",
|
| 59 |
+
"start": 22,
|
| 60 |
+
"end": 30,
|
| 61 |
+
},
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
highlighted_text = "Does Chicago have any Pakistani restaurants"
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def random_model3d():
|
| 68 |
+
model_3d = random.choice(
|
| 69 |
+
[os.path.join(model3d_dir, model) for model in os.listdir(model3d_dir) if model != "source.txt"]
|
| 70 |
+
)
|
| 71 |
+
return model_3d
|