Spaces:
Sleeping
Sleeping
Jay
#1
by jaypatel011 - opened
- README.md +1 -1
- create_games/data/game_ideas.json +3 -3
- home_view/__pycache__/ui_home.cpython-311.pyc +0 -0
- home_view/art/logo.png +0 -0
- home_view/ui_home.py +8 -9
- requirements.txt +3 -3
- sketch/__pycache__/sketch.cpython-311.pyc +0 -0
- sketch/sketch.py +4 -15
- utilities/__pycache__/constants.cpython-311.pyc +0 -0
- utilities/constants.py +4 -5
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🤸
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.40.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
create_games/data/game_ideas.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
-
"Name": "
|
| 4 |
-
"Description": "
|
| 5 |
-
"Rationale": "This game
|
| 6 |
}
|
| 7 |
]
|
|
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
+
"Name": "Family Portraits",
|
| 4 |
+
"Description": "Each player takes turns drawing a portrait of their family. The other players must guess who is in the portrait. The player with the most correct guesses wins.",
|
| 5 |
+
"Rationale": "This game encourages creativity and allows players to learn more about each other's families."
|
| 6 |
}
|
| 7 |
]
|
home_view/__pycache__/ui_home.cpython-311.pyc
CHANGED
|
Binary files a/home_view/__pycache__/ui_home.cpython-311.pyc and b/home_view/__pycache__/ui_home.cpython-311.pyc differ
|
|
|
home_view/art/logo.png
DELETED
|
Binary file (4.59 kB)
|
|
|
home_view/ui_home.py
CHANGED
|
@@ -25,7 +25,7 @@ def FetchData():
|
|
| 25 |
return startDF, slackDF, embeddingsDF, playersDF, gamesDF
|
| 26 |
|
| 27 |
def Init():
|
| 28 |
-
global startDF, slackDF, embeddingsDF, gamesDF,playersDF,playersValues
|
| 29 |
startDF=FetchSlack()
|
| 30 |
slackDF=ProcessSlack()
|
| 31 |
embeddingsDF=CreateEmbeddings()
|
|
@@ -72,12 +72,12 @@ df3 =gr.Dataframe(type="pandas", value=embeddingsDF)
|
|
| 72 |
df4 =gr.Dataframe(type="pandas", value= playersDF)
|
| 73 |
df5 =gr.Dataframe(type="pandas", value=gamesDF)
|
| 74 |
|
| 75 |
-
with gr.Blocks() as ui:
|
| 76 |
-
with gr.
|
| 77 |
-
logo=gr.Image(value=
|
| 78 |
directions= gr.Markdown(constants.DIRECTIONS, container=False)
|
| 79 |
with gr.Column():
|
| 80 |
-
playersCB = gr.CheckboxGroup ([], label=constants.PLAYERS, info=constants.PLAYERS_INFO )
|
| 81 |
createBtn = gr.Button(value=constants.CREATE_GAME, variant="primary")
|
| 82 |
gameTitle=gr.Markdown(constants.GAME_TITLE, container=False)
|
| 83 |
desc=gr.TextArea(info=constants.GAME_DESC, interactive=False, show_label=False,
|
|
@@ -88,15 +88,14 @@ with gr.Blocks() as ui:
|
|
| 88 |
brush_radius=.5, type="numpy", label="Sketch", show_label=True, show_download_button=False)
|
| 89 |
label=gr.Label()
|
| 90 |
sketch.change(Predict, inputs=[sketch], outputs=[label])
|
| 91 |
-
playersCB.change(SetSelected, inputs=[playersCB], outputs=[])
|
| 92 |
-
createBtn.click(CreateGame, inputs=[], outputs=[df4,desc,gameTitle])
|
| 93 |
-
playBtn.click(PlayGame, inputs=[], outputs=[holder])
|
| 94 |
|
| 95 |
with gr.Blocks() as dfs:
|
| 96 |
fetchBtn=gr.Button(value=constants.FETCH_DATA, variant="primary")
|
| 97 |
gr.TabbedInterface([df1,df2,df3,df4,df5], (constants.UI1, constants.UI2, constants.UI3, constants.UI4, constants.UI5), theme=SoftBlue())
|
| 98 |
fetchBtn.click(FetchData, inputs=[], outputs=[df1,df2,df3,df4,df5])
|
| 99 |
-
|
|
|
|
|
|
|
| 100 |
|
| 101 |
combo=gr.TabbedInterface([ui,dfs], ("BuildPlay", "DataFrames"),theme=SoftBlue())
|
| 102 |
|
|
|
|
| 25 |
return startDF, slackDF, embeddingsDF, playersDF, gamesDF
|
| 26 |
|
| 27 |
def Init():
|
| 28 |
+
global startDF, slackDF, embeddingsDF, gamesDF,playersDF,playersValues
|
| 29 |
startDF=FetchSlack()
|
| 30 |
slackDF=ProcessSlack()
|
| 31 |
embeddingsDF=CreateEmbeddings()
|
|
|
|
| 72 |
df4 =gr.Dataframe(type="pandas", value= playersDF)
|
| 73 |
df5 =gr.Dataframe(type="pandas", value=gamesDF)
|
| 74 |
|
| 75 |
+
with gr.Blocks() as ui:
|
| 76 |
+
with gr.Row():
|
| 77 |
+
logo=gr.Image(value=constants.BUILDPLAY_LOGO, width=200, height=200, show_download_button=False, container=False)
|
| 78 |
directions= gr.Markdown(constants.DIRECTIONS, container=False)
|
| 79 |
with gr.Column():
|
| 80 |
+
playersCB = gr.CheckboxGroup ([], type="value", label=constants.PLAYERS, info=constants.PLAYERS_INFO )
|
| 81 |
createBtn = gr.Button(value=constants.CREATE_GAME, variant="primary")
|
| 82 |
gameTitle=gr.Markdown(constants.GAME_TITLE, container=False)
|
| 83 |
desc=gr.TextArea(info=constants.GAME_DESC, interactive=False, show_label=False,
|
|
|
|
| 88 |
brush_radius=.5, type="numpy", label="Sketch", show_label=True, show_download_button=False)
|
| 89 |
label=gr.Label()
|
| 90 |
sketch.change(Predict, inputs=[sketch], outputs=[label])
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
with gr.Blocks() as dfs:
|
| 93 |
fetchBtn=gr.Button(value=constants.FETCH_DATA, variant="primary")
|
| 94 |
gr.TabbedInterface([df1,df2,df3,df4,df5], (constants.UI1, constants.UI2, constants.UI3, constants.UI4, constants.UI5), theme=SoftBlue())
|
| 95 |
fetchBtn.click(FetchData, inputs=[], outputs=[df1,df2,df3,df4,df5])
|
| 96 |
+
playersCB.change(SetSelected, inputs=[playersCB], outputs=[])
|
| 97 |
+
createBtn.click(CreateGame, inputs=[], outputs=[df4,desc,gameTitle])
|
| 98 |
+
playBtn.click(PlayGame, inputs=[], outputs=[holder])
|
| 99 |
|
| 100 |
combo=gr.TabbedInterface([ui,dfs], ("BuildPlay", "DataFrames"),theme=SoftBlue())
|
| 101 |
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
pip>=
|
| 2 |
requests==2.31.0
|
| 3 |
pylance==0.5.10
|
| 4 |
pandas==2.0.3
|
|
@@ -9,8 +9,8 @@ scikit-learn==1.2.2
|
|
| 9 |
plotly.express==0.4.1
|
| 10 |
openai==0.27.8
|
| 11 |
openapi-schema-pydantic==1.2.4
|
| 12 |
-
gradio==3.
|
| 13 |
-
gradio_client==0.
|
| 14 |
GitPython==3.1.31
|
| 15 |
elevenlabs==0.2.18
|
| 16 |
python-dotenv==1.0.0
|
|
|
|
| 1 |
+
pip>=21.3
|
| 2 |
requests==2.31.0
|
| 3 |
pylance==0.5.10
|
| 4 |
pandas==2.0.3
|
|
|
|
| 9 |
plotly.express==0.4.1
|
| 10 |
openai==0.27.8
|
| 11 |
openapi-schema-pydantic==1.2.4
|
| 12 |
+
gradio==3.39.0
|
| 13 |
+
gradio_client==0.3.0
|
| 14 |
GitPython==3.1.31
|
| 15 |
elevenlabs==0.2.18
|
| 16 |
python-dotenv==1.0.0
|
sketch/__pycache__/sketch.cpython-311.pyc
CHANGED
|
Binary files a/sketch/__pycache__/sketch.cpython-311.pyc and b/sketch/__pycache__/sketch.cpython-311.pyc differ
|
|
|
sketch/sketch.py
CHANGED
|
@@ -27,34 +27,23 @@ model.load_state_dict(state_dict, strict=False)
|
|
| 27 |
model.eval()
|
| 28 |
|
| 29 |
def Predict(img):
|
| 30 |
-
if img is None or not img.any():
|
| 31 |
-
print("img is None or empty")
|
| 32 |
-
# Handle the error appropriately
|
| 33 |
-
return
|
| 34 |
-
|
| 35 |
# Convert to grayscale if the image is RGB
|
| 36 |
-
if img
|
| 37 |
-
|
| 38 |
-
|
| 39 |
# Convert the NumPy array to a PIL image
|
| 40 |
img_pil = Image.fromarray(img.astype('uint8'))
|
| 41 |
-
|
| 42 |
# Resize the image
|
| 43 |
-
img_resized = img_pil.resize((28, 28), Image.ANTIALIAS)
|
| 44 |
-
|
| 45 |
# Convert the PIL image back to a NumPy array
|
| 46 |
img_np = np.array(img_resized)
|
| 47 |
-
|
| 48 |
# Convert to tensor and normalize
|
| 49 |
x = torch.tensor(img_np, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.0
|
| 50 |
-
|
| 51 |
# Model prediction
|
| 52 |
with torch.no_grad():
|
| 53 |
out = model(x)
|
| 54 |
-
|
| 55 |
probabilities = torch.nn.functional.softmax(out[0], dim=0)
|
| 56 |
values, indices = torch.topk(probabilities, 5)
|
| 57 |
confidences = {LABELS[i]: v.item() for i, v in zip(indices, values)}
|
| 58 |
-
|
| 59 |
return confidences
|
| 60 |
|
|
|
|
| 27 |
model.eval()
|
| 28 |
|
| 29 |
def Predict(img):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# Convert to grayscale if the image is RGB
|
| 31 |
+
if img is not None and img.any():
|
| 32 |
+
if img.shape[-1] == 3:
|
| 33 |
+
img = np.mean(img, axis=-1)
|
| 34 |
# Convert the NumPy array to a PIL image
|
| 35 |
img_pil = Image.fromarray(img.astype('uint8'))
|
|
|
|
| 36 |
# Resize the image
|
| 37 |
+
img_resized = img_pil.resize((28, 28), Image.ANTIALIAS)
|
|
|
|
| 38 |
# Convert the PIL image back to a NumPy array
|
| 39 |
img_np = np.array(img_resized)
|
|
|
|
| 40 |
# Convert to tensor and normalize
|
| 41 |
x = torch.tensor(img_np, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.0
|
|
|
|
| 42 |
# Model prediction
|
| 43 |
with torch.no_grad():
|
| 44 |
out = model(x)
|
|
|
|
| 45 |
probabilities = torch.nn.functional.softmax(out[0], dim=0)
|
| 46 |
values, indices = torch.topk(probabilities, 5)
|
| 47 |
confidences = {LABELS[i]: v.item() for i, v in zip(indices, values)}
|
|
|
|
| 48 |
return confidences
|
| 49 |
|
utilities/__pycache__/constants.cpython-311.pyc
CHANGED
|
Binary files a/utilities/__pycache__/constants.cpython-311.pyc and b/utilities/__pycache__/constants.cpython-311.pyc differ
|
|
|
utilities/constants.py
CHANGED
|
@@ -10,11 +10,10 @@ NO_GAME="No game created"
|
|
| 10 |
NO_GAME_TITLE="Game Title: No game created"
|
| 11 |
PLAY_GAME="Play Game"
|
| 12 |
BUILDPLAY_LOGO="home_view/art/buildPlay.svg"
|
| 13 |
-
|
| 14 |
FETCH_DATA="Fetch data"
|
| 15 |
|
| 16 |
UI1="Slack"
|
| 17 |
-
UI2="
|
| 18 |
-
UI3="
|
| 19 |
-
UI4="
|
| 20 |
-
UI5="
|
|
|
|
| 10 |
NO_GAME_TITLE="Game Title: No game created"
|
| 11 |
PLAY_GAME="Play Game"
|
| 12 |
BUILDPLAY_LOGO="home_view/art/buildPlay.svg"
|
|
|
|
| 13 |
FETCH_DATA="Fetch data"
|
| 14 |
|
| 15 |
UI1="Slack"
|
| 16 |
+
UI2="Themes"
|
| 17 |
+
UI3="Embeddings"
|
| 18 |
+
UI4="Topics by Player"
|
| 19 |
+
UI5="Games"
|