Spaces:
Running
Running
luet
commited on
Commit
·
7b1f6d1
1
Parent(s):
ecfb771
edit
Browse files- app.py +51 -19
- models.json +4 -4
app.py
CHANGED
@@ -22,57 +22,89 @@ def display_models():
|
|
22 |
models = load_models()
|
23 |
if not models:
|
24 |
return "No models have been added yet."
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
output +=
|
29 |
-
output += f"
|
30 |
-
output += "
|
|
|
|
|
|
|
|
|
31 |
return output
|
32 |
|
33 |
# Function to add a new model
|
34 |
-
def add_model(name, description,
|
35 |
models = load_models()
|
36 |
-
models.append({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
save_models(models)
|
38 |
return "Model added successfully!", display_models()
|
39 |
|
40 |
# Function to edit an existing model
|
41 |
-
def edit_model(index, name, description,
|
42 |
models = load_models()
|
43 |
if index < 1 or index > len(models):
|
44 |
return "Invalid index. Please provide a valid model number.", display_models()
|
45 |
-
models[index - 1] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
save_models(models)
|
47 |
return "Model updated successfully!", display_models()
|
48 |
|
49 |
# Gradio interface
|
50 |
with gr.Blocks() as app:
|
51 |
-
gr.Markdown("# AI
|
52 |
|
53 |
-
with gr.Tab("View
|
54 |
-
view_button = gr.Button("Refresh
|
55 |
-
view_output = gr.
|
56 |
view_button.click(display_models, outputs=view_output)
|
57 |
|
58 |
with gr.Tab("Add Model"):
|
59 |
with gr.Row():
|
60 |
name_input = gr.Textbox(label="Model Name", placeholder="Enter model name")
|
61 |
-
year_input = gr.Textbox(label="Publication
|
62 |
description_input = gr.Textbox(label="Description", placeholder="Enter a short description")
|
|
|
|
|
|
|
63 |
add_button = gr.Button("Add Model")
|
64 |
add_output = gr.Markdown()
|
65 |
-
add_button.click(
|
|
|
|
|
|
|
|
|
66 |
|
67 |
with gr.Tab("Edit Model"):
|
68 |
edit_index = gr.Number(label="Model Number", precision=0)
|
69 |
with gr.Row():
|
70 |
edit_name = gr.Textbox(label="New Model Name", placeholder="Enter new model name")
|
71 |
-
edit_year = gr.Textbox(label="New Publication
|
72 |
edit_description = gr.Textbox(label="New Description", placeholder="Enter new description")
|
|
|
|
|
|
|
73 |
edit_button = gr.Button("Edit Model")
|
74 |
edit_output = gr.Markdown()
|
75 |
-
edit_button.click(
|
|
|
|
|
|
|
|
|
76 |
|
77 |
# Run the app
|
78 |
-
app.launch()
|
|
|
22 |
models = load_models()
|
23 |
if not models:
|
24 |
return "No models have been added yet."
|
25 |
+
models = sorted(models, key=lambda x: x['dateOfRelease']) # Sort by release date
|
26 |
+
output = "" # Prepare HTML output for timeline
|
27 |
+
for model in models:
|
28 |
+
output += "<div style='border: 1px solid #ccc; border-radius: 10px; padding: 10px; margin: 10px;'>"
|
29 |
+
output += f"<h3>{model['name']} ({model['dateOfRelease']})</h3>"
|
30 |
+
output += f"<p><strong>Description:</strong> {model['description']}</p>"
|
31 |
+
output += f"<p><strong>Developer:</strong> {model.get('developer', 'Unknown')}</p>"
|
32 |
+
output += f"<p><strong>Use Case:</strong> {model.get('use_case', 'General')}</p>"
|
33 |
+
output += f"<p><strong>Impact:</strong> {model.get('impact', 'Not specified')}</p>"
|
34 |
+
output += "</div>"
|
35 |
return output
|
36 |
|
37 |
# Function to add a new model
|
38 |
+
def add_model(name, description, dateOfRelease, developer, use_case, impact):
|
39 |
models = load_models()
|
40 |
+
models.append({
|
41 |
+
"name": name,
|
42 |
+
"description": description,
|
43 |
+
"dateOfRelease": dateOfRelease,
|
44 |
+
"developer": developer,
|
45 |
+
"use_case": use_case,
|
46 |
+
"impact": impact
|
47 |
+
})
|
48 |
save_models(models)
|
49 |
return "Model added successfully!", display_models()
|
50 |
|
51 |
# Function to edit an existing model
|
52 |
+
def edit_model(index, name, description, dateOfRelease, developer, use_case, impact):
|
53 |
models = load_models()
|
54 |
if index < 1 or index > len(models):
|
55 |
return "Invalid index. Please provide a valid model number.", display_models()
|
56 |
+
models[index - 1] = {
|
57 |
+
"name": name,
|
58 |
+
"description": description,
|
59 |
+
"dateOfRelease": dateOfRelease,
|
60 |
+
"developer": developer,
|
61 |
+
"use_case": use_case,
|
62 |
+
"impact": impact
|
63 |
+
}
|
64 |
save_models(models)
|
65 |
return "Model updated successfully!", display_models()
|
66 |
|
67 |
# Gradio interface
|
68 |
with gr.Blocks() as app:
|
69 |
+
gr.Markdown("# AI Timeline\n\nVisualize the development of AI models through an interactive timeline.")
|
70 |
|
71 |
+
with gr.Tab("View Timeline"):
|
72 |
+
view_button = gr.Button("Refresh Timeline")
|
73 |
+
view_output = gr.HTML(display_models())
|
74 |
view_button.click(display_models, outputs=view_output)
|
75 |
|
76 |
with gr.Tab("Add Model"):
|
77 |
with gr.Row():
|
78 |
name_input = gr.Textbox(label="Model Name", placeholder="Enter model name")
|
79 |
+
year_input = gr.Textbox(label="Publication Date", placeholder="Enter date of publication (YYYY-MM-DD)")
|
80 |
description_input = gr.Textbox(label="Description", placeholder="Enter a short description")
|
81 |
+
developer_input = gr.Textbox(label="Developer", placeholder="Enter the developer or organization")
|
82 |
+
use_case_input = gr.Textbox(label="Use Case", placeholder="Enter the primary use case")
|
83 |
+
impact_input = gr.Textbox(label="Impact", placeholder="Enter the model's impact")
|
84 |
add_button = gr.Button("Add Model")
|
85 |
add_output = gr.Markdown()
|
86 |
+
add_button.click(
|
87 |
+
add_model,
|
88 |
+
inputs=[name_input, description_input, year_input, developer_input, use_case_input, impact_input],
|
89 |
+
outputs=[add_output, view_output]
|
90 |
+
)
|
91 |
|
92 |
with gr.Tab("Edit Model"):
|
93 |
edit_index = gr.Number(label="Model Number", precision=0)
|
94 |
with gr.Row():
|
95 |
edit_name = gr.Textbox(label="New Model Name", placeholder="Enter new model name")
|
96 |
+
edit_year = gr.Textbox(label="New Publication Date", placeholder="Enter new date of publication (YYYY-MM-DD)")
|
97 |
edit_description = gr.Textbox(label="New Description", placeholder="Enter new description")
|
98 |
+
edit_developer = gr.Textbox(label="New Developer", placeholder="Enter new developer or organization")
|
99 |
+
edit_use_case = gr.Textbox(label="New Use Case", placeholder="Enter new primary use case")
|
100 |
+
edit_impact = gr.Textbox(label="New Impact", placeholder="Enter new impact")
|
101 |
edit_button = gr.Button("Edit Model")
|
102 |
edit_output = gr.Markdown()
|
103 |
+
edit_button.click(
|
104 |
+
edit_model,
|
105 |
+
inputs=[edit_index, edit_name, edit_description, edit_year, edit_developer, edit_use_case, edit_impact],
|
106 |
+
outputs=[edit_output, view_output]
|
107 |
+
)
|
108 |
|
109 |
# Run the app
|
110 |
+
app.launch()
|
models.json
CHANGED
@@ -2,21 +2,21 @@
|
|
2 |
{
|
3 |
"name": "GPT-3",
|
4 |
"description": "A language model capable of generating human-like text.",
|
5 |
-
"
|
6 |
},
|
7 |
{
|
8 |
"name": "BERT",
|
9 |
"description": "A model for natural language understanding tasks like question answering and sentiment analysis.",
|
10 |
-
"
|
11 |
},
|
12 |
{
|
13 |
"name": "DALL·E",
|
14 |
"description": "A model for generating images from textual descriptions.",
|
15 |
-
"
|
16 |
},
|
17 |
{
|
18 |
"name": "ResNet",
|
19 |
"description": "A deep convolutional network for image recognition tasks.",
|
20 |
-
"
|
21 |
}
|
22 |
]
|
|
|
2 |
{
|
3 |
"name": "GPT-3",
|
4 |
"description": "A language model capable of generating human-like text.",
|
5 |
+
"dateOfRelease": "2020"
|
6 |
},
|
7 |
{
|
8 |
"name": "BERT",
|
9 |
"description": "A model for natural language understanding tasks like question answering and sentiment analysis.",
|
10 |
+
"dateOfRelease": "2018"
|
11 |
},
|
12 |
{
|
13 |
"name": "DALL·E",
|
14 |
"description": "A model for generating images from textual descriptions.",
|
15 |
+
"dateOfRelease": "2021"
|
16 |
},
|
17 |
{
|
18 |
"name": "ResNet",
|
19 |
"description": "A deep convolutional network for image recognition tasks.",
|
20 |
+
"dateOfRelease": "2015"
|
21 |
}
|
22 |
]
|