Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
4 |
+
|
5 |
+
def update_table(category):
|
6 |
+
data_dict = {
|
7 |
+
"Overall": {
|
8 |
+
"Rank": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],
|
9 |
+
"Model": ["Model A", "Model B", "Model C", "Model D", "Model E", "Model F", "Model G", "Model H", "Model I", "Model J", "Model K", "Model L", "Model M", "Model N", "Model O", "Model P", "Model Q", "Model R", "Model S", "Model T", "Model U", "Model V", "Model W", "Model X", "Model Y", "Model Z", "Model A", "Model B", "Model C", "Model D", "Model E", "Model F", "Model G", "Model H", "Model I", "Model J", "Model K", "Model L", "Model M", "Model N", "Model O", "Model P", "Model Q", "Model R", "Model S", "Model T", "Model U", "Model V", "Model W", "Model X", "Model Y", "Model Z"],
|
10 |
+
"Votes": [1250, 200, 3150, 4250, 5200, 6150, 7250, 8200, 9150, 10250, 11200, 12150, 13250, 21250, 200, 3150, 4250, 5200, 6150, 7250, 8200, 9150, 10250, 11200, 12150, 13250, 1250, 200, 3150, 4250, 5200, 6150, 7250, 8200, 9150, 10250, 11200, 12150, 13250, 21250, 200, 3150, 4250, 5200, 6150, 7250, 8200, 9150, 10250, 11200, 12150, 13250],
|
11 |
+
"Organization": ["Org A", "Org B", "Org C", "Org D", "Org E", "Org F", "Org G", "Org H", "Org I", "Org J", "Org K", "Org L", "Org M", "Org N", "Org O", "Org P", "Org Q", "Model R", "Model S", "Model T", "Model U", "Model V", "Model W", "Model X", "Model Y", "Model Z", "Org A", "Org B", "Org C", "Org D", "Org E", "Org F", "Org G", "Org H", "Org I", "Org J", "Org K", "Org L", "Org M", "Org N", "Org O", "Org P", "Org Q", "Model R", "Model S", "Model T", "Model U", "Model V", "Model W", "Model X", "Model Y", "Model Z"],
|
12 |
+
"License": ["1MIT", "2Apache 2.0", "3GPL", "4MIT", "5Apache 2.0", "6GPL", "7MIT", "8Apache 2.0", "9GPL", "10MIT", "11Apache 2.0", "12GPL", "13MIT", "1MIT", "2Apache 2.0", "3GPL", "4MIT", "5Apache 2.0", "6GPL", "7MIT", "8Apache 2.0", "9GPL", "10MIT", "11Apache 2.0", "12GPL", "13MIT", "1MIT", "2Apache 2.0", "3GPL", "4MIT", "5Apache 2.0", "6GPL", "7MIT", "8Apache 2.0", "9GPL", "10MIT", "11Apache 2.0", "12GPL", "13MIT", "1MIT", "2Apache 2.0", "3GPL", "4MIT", "5Apache 2.0", "6GPL", "7MIT", "8Apache 2.0", "9GPL", "10MIT", "11Apache 2.0", "12GPL", "13MIT"]
|
13 |
+
},
|
14 |
+
"Biology": {
|
15 |
+
"Rank": [1, 2],
|
16 |
+
"Model": ["GenePredict", "BioSeq"],
|
17 |
+
"Votes": [180, 160],
|
18 |
+
"Organization": ["BioTech", "Genomics Inc"],
|
19 |
+
"License": ["GPL", "MIT"]
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
data = data_dict.get(category, {"Rank": [], "Model": [], "Votes": [], "Organization": [], "License": []})
|
24 |
+
df = pd.DataFrame(data)
|
25 |
+
return df
|
26 |
+
|
27 |
+
def submit_vote(vote):
|
28 |
+
# code
|
29 |
+
return f"Vote '{vote}' submitted successfully!"
|
30 |
+
|
31 |
+
def submit_model(model_id):
|
32 |
+
if not model_id:
|
33 |
+
return "All fields are required!"
|
34 |
+
|
35 |
+
url = "https://sdk.nexa4ai.com/task" # Will have a new endpoint
|
36 |
+
|
37 |
+
data = {
|
38 |
+
"model_id": model_id
|
39 |
+
}
|
40 |
+
|
41 |
+
response = requests.post(url, json=data)
|
42 |
+
|
43 |
+
if response.status_code == 200:
|
44 |
+
return "Your request has been submitted successfully. We will notify you by email once processing is complete."
|
45 |
+
else:
|
46 |
+
return f"Failed to submit request: {response.text}"
|
47 |
+
|
48 |
+
|
49 |
+
with gr.Blocks() as app:
|
50 |
+
with gr.Tabs():
|
51 |
+
with gr.TabItem("Table"):
|
52 |
+
dropdown = gr.Dropdown(
|
53 |
+
choices=[
|
54 |
+
"Overall", "Biology", "Physics", "Business", "Chemistry",
|
55 |
+
"Economics", "Philosophy", "History", "Culture", "Computer Science",
|
56 |
+
"Math", "Health", "Law", "Engineering", "Other"
|
57 |
+
],
|
58 |
+
label="Select Category",
|
59 |
+
value="Overall"
|
60 |
+
)
|
61 |
+
|
62 |
+
initial_data = update_table("Overall")
|
63 |
+
table = gr.Dataframe(
|
64 |
+
headers=["Rank", "Model", "Votes", "Organization", "License"],
|
65 |
+
datatype=["number", "str", "number", "str", "str"],
|
66 |
+
value=initial_data,
|
67 |
+
col_count=(5, "fixed"),
|
68 |
+
# height=600
|
69 |
+
)
|
70 |
+
dropdown.change(update_table, inputs=dropdown, outputs=table)
|
71 |
+
|
72 |
+
with gr.TabItem("Vote"):
|
73 |
+
vote = gr.Radio(choices=["Option 1", "Option 2", "Option 3"], label="Choose your option")
|
74 |
+
submit_button = gr.Button("Submit Vote")
|
75 |
+
submit_result = gr.Label()
|
76 |
+
submit_button.click(fn=submit_vote, inputs=vote, outputs=submit_result)
|
77 |
+
|
78 |
+
with gr.TabItem("Submit Model"):
|
79 |
+
model_id = HuggingfaceHubSearch(
|
80 |
+
label="Hub Model ID",
|
81 |
+
placeholder="Search for model id on Huggingface",
|
82 |
+
search_type="model",
|
83 |
+
)
|
84 |
+
submit_model_button = gr.Button("Submit Model")
|
85 |
+
submit_model_result = gr.Label()
|
86 |
+
submit_model_button.click(fn=submit_model, inputs=[model_id], outputs=submit_model_result)
|
87 |
+
|
88 |
+
app.launch()
|