Spaces:
Build error
Build error
Kim Adams commited on
Commit ·
53b3fd3
1
Parent(s): 3cb704e
reverting draw to smaller
Browse filesFiles changed (7)
123456789[{"Name": "Diagnostic Draw","Description": "A drawing-based game to illustrate various illnesses","Rules": "1. Each player takes turns drawing a single thing that represents an illness.\n2. The illness should be common and easily relatable.\n3. Players take turns guessing the illness being drawn.","Tips": "Can you draw a symbol that represents a headache?","InitialQuestion": "Draw a simple symbol that represents a cough."}]123456789[{"Name": "Blazing Sunburn","Description": "A drawing-based game where players try to draw a humorous sunburn-related scenario.","Rules": "1. Each player takes turns to draw a sunburn-related scene or situation.\n2. Players have limited time to complete their drawing.\n3. The drawings should aim to be creative and humorous.","Tips": "Can you draw a person with funny shaped sunburns? How about an unconventional object getting sunburnt?","InitialQuestion": "Draw a person with a sunburn that resembles something else."}]
143 unmodified lines1441451461471481491501511521531541551561571581591601611621634 unmodified lines168169170171172173174175143 unmodified linesbuildPlayLabel= gr.Markdown(constants.BUILDPLAY_LABEL, container=False)with gr.Column():directionsLabel= gr.Markdown(constants.DIRECTIONS_LABEL, container=False)directions= gr.Markdown(constants.DIRECTIONS, container=False)playersCB = gr.CheckboxGroup ([], label=constants.PLAYERS, info=constants.PLAYERS_INFO )gamePlay=gr.Radio(["Draw", "Chat"], label=constants.GAME_TYPE, value="Chat")createBtn = gr.Button(value=constants.CREATE_GAME, variant="primary")with gr.Column(visible=False) as pGame:with gr.Row():with gr.Column():chatTitle= gr.Markdown ()chatDesc= gr.Markdown ()gameTopic=gr.Markdown()players=gr.Markdown()with gr.Column():rules=gr.Markdown(constants.RULES_LABEL)chatRules=gr.Markdown(constants.GAME_DESC)4 unmodified linesdrawMD=gr.Markdown()with gr.Column(visible=False) as drawGame:with gr.Row():sketch=gr.Image(image_mode="L", source="canvas", width=600, height =600, invert_colors=True, interactive=True,brush_radius=.5, type="numpy", label="Sketch", show_label=True, show_download_button=False)label=gr.Label(label="Guesses", show_label=True)resetDrwBtn=gr.Button(value="Reset")with gr.Column(visible=False) as chatGame:143 unmodified lines1441451461471481491501511521531541551561571581591604 unmodified lines165166167168169170171172173143 unmodified linesbuildPlayLabel= gr.Markdown(constants.BUILDPLAY_LABEL, container=False)with gr.Column():directionsLabel= gr.Markdown(constants.DIRECTIONS_LABEL, container=False)directions= gr.Markdown(constants.DIRECTIONS, container=False)playersCB = gr.CheckboxGroup ([], label=constants.PLAYERS, info=constants.PLAYERS_INFO )gamePlay=gr.Radio(["Draw", "Chat"], label=constants.GAME_TYPE, value="Chat")createBtn = gr.Button(value=constants.CREATE_GAME, variant="primary")with gr.Column(visible=False) as pGame:with gr.Row():with gr.Column():chatTitle= gr.Markdown ()chatDesc= gr.Markdown ()gameTopic=gr.Markdown()players=gr.Markdown()with gr.Column():rules=gr.Markdown(constants.RULES_LABEL)chatRules=gr.Markdown(constants.GAME_DESC)4 unmodified linesdrawMD=gr.Markdown()with gr.Column(visible=False) as drawGame:with gr.Row():sketch=gr.Image(image_mode="L", source="canvas",brush_radius=5, type="pil", shape=(120, 120),invert_colors=True, interactive=True, label="Sketch",show_label=True, show_download_button=False)label=gr.Label(label="Guesses", show_label=True)resetDrwBtn=gr.Button(value="Reset")with gr.Column(visible=False) as chatGame:
123version https://git-lfs.github.com/spec/v1oid sha256:effb6ea6f1593c09e8247944028ed9c309b5ff1cef82ba38b822bee2ca4d0f3csize 165690321 unmodified lines2223242521 unmodified linestorch==2.0.1inflect==7.0.0Pillow==10.1.0streamlit==1.28.021 unmodified lines22232425262721 unmodified linestorch==2.0.1inflect==7.0.0Pillow==10.1.0streamlit==1.28.0gdown==4.7.1PySocks==1.7.1
2 unmodified lines3456789101110 unmodified lines22232425262728293031327 unmodified lines4041424344454610 unmodified lines57585960612 unmodified linesimport numpy as npfrom torch import nnfrom pathlib import PathPATH="sketch/class_names.txt"LABELS = Path(PATH).read_text().splitlines()model = nn.Sequential(nn.Conv2d(1, 32, 3, padding='same'),10 unmodified linesnn.ReLU(),nn.Linear(256, len(LABELS)),)state_dict = torch.load('sketch/pytorch_model.bin', map_location='cpu')model.load_state_dict(state_dict, strict=False)model.eval()def Predict(img):if img is None or not img.any():print("img is None or empty")# Handle the error appropriately7 unmodified linesimg_pil = Image.fromarray(img.astype('uint8'))# Resize the image#img_resized = img_pil.resize((28, 28), Image.ANTIALIAS)img_resized = img_pil.resize((28, 28), Image.LANCZOS)# Convert the PIL image back to a NumPy array10 unmodified linesvalues, indices = torch.topk(probabilities, 5)confidences = {LABELS[i]: v.item() for i, v in zip(indices, values)}return confidences2 unmodified lines345678910111213141516171810 unmodified lines29303132333435363738397 unmodified lines47484950515210 unmodified lines636465666768697071727374757677787980818283842 unmodified linesimport numpy as npfrom torch import nnfrom pathlib import Pathimport gdown#PATH="sketch/class_names.txt"#LABELS = Path(PATH).read_text().splitlines()url = 'https://drive.google.com/uc?id=1dsk2JNZLRDjC-0J4wIQX_FcVurPaXaAZ'output = 'pytorch_model.bin'gdown.download(url, output, quiet=False)LABELS = Path('sketch/class_names.txt').read_text().splitlines()model = nn.Sequential(nn.Conv2d(1, 32, 3, padding='same'),10 unmodified linesnn.ReLU(),nn.Linear(256, len(LABELS)),)state_dict = torch.load('sketch/pytorch_model.bin',map_location='cpu')model.load_state_dict(state_dict, strict=False)model.eval()'''def Predict(img):if img is None or not img.any():print("img is None or empty")# Handle the error appropriately7 unmodified linesimg_pil = Image.fromarray(img.astype('uint8'))# Resize the imageimg_resized = img_pil.resize((28, 28), Image.LANCZOS)# Convert the PIL image back to a NumPy array10 unmodified linesvalues, indices = torch.topk(probabilities, 5)confidences = {LABELS[i]: v.item() for i, v in zip(indices, values)}return confidences'''def Predict(im):if im is None:print("img is None or empty")# Handle the error appropriatelyreturnim = np.asarray(im.resize((28, 28)))x = torch.tensor(im, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.with torch.no_grad():out = model(x)probabilities = torch.nn.functional.softmax(out[0], dim=0)values, indices = torch.topk(probabilities, 5)return {LABELS[i]: v.item() for i, v in zip(indices, values)}
create_games/data/game_ideas.json+5-5
home_view/__pycache__/ui_home.cpython-311.pyc
home_view/ui_home.py+5-7
pytorch_model.binAdded+3
requirements.txt+3-1
sketch/__pycache__/sketch.cpython-311.pyc
sketch/sketch.py+29-6