Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,217 +1,142 @@
|
|
| 1 |
-
import time
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
-
from
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
# Windows 95 custom CSS for authentic styling
|
| 9 |
-
WINDOWS_95_CSS = """
|
| 10 |
-
/* Windows 95 Taskbar Footer */
|
| 11 |
-
footer {
|
| 12 |
-
position: fixed !important;
|
| 13 |
-
bottom: 0 !important;
|
| 14 |
-
left: 0 !important;
|
| 15 |
-
right: 0 !important;
|
| 16 |
-
margin: 0 !important;
|
| 17 |
-
padding: 4px 8px !important;
|
| 18 |
-
background: #C0C0C0 !important;
|
| 19 |
-
border-top: 2px solid #FFFFFF !important;
|
| 20 |
-
box-shadow: inset 0 1px 0 0 #DFDFDF, inset 0 -1px 0 0 #808080, 0 -1px 0 0 #404040 !important;
|
| 21 |
-
justify-content: flex-start !important;
|
| 22 |
-
gap: 8px !important;
|
| 23 |
-
z-index: 9999 !important;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
footer button, footer a {
|
| 27 |
-
background: #C0C0C0 !important;
|
| 28 |
-
color: #000000 !important;
|
| 29 |
-
border: none !important;
|
| 30 |
-
padding: 4px 12px !important;
|
| 31 |
-
box-shadow: inset -1px -1px 0px 0px #808080, inset 1px 1px 0px 0px #FFFFFF, inset -2px -2px 0px 0px #404040, inset 2px 2px 0px 0px #DFDFDF !important;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
footer .divider { display: none !important; }
|
| 35 |
-
footer img, button img, a img, svg { box-shadow: none !important; }
|
| 36 |
-
.gradio-container { padding-bottom: 40px !important; }
|
| 37 |
-
|
| 38 |
-
/* 3D Buttons */
|
| 39 |
-
button { border-radius: 0 !important; }
|
| 40 |
-
|
| 41 |
-
/* Sunken inputs */
|
| 42 |
-
input, textarea, select {
|
| 43 |
-
border-radius: 0 !important;
|
| 44 |
-
box-shadow: inset 1px 1px 0px 0px #808080, inset -1px -1px 0px 0px #FFFFFF, inset 2px 2px 0px 0px #404040, inset -2px -2px 0px 0px #DFDFDF !important;
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
/* Windows 95 Scrollbars */
|
| 48 |
-
*::-webkit-scrollbar { width: 16px !important; height: 16px !important; }
|
| 49 |
-
*::-webkit-scrollbar-track { background: #DFDFDF !important; }
|
| 50 |
-
*::-webkit-scrollbar-thumb {
|
| 51 |
-
background: #C0C0C0 !important;
|
| 52 |
-
box-shadow: inset -1px -1px 0px 0px #808080, inset 1px 1px 0px 0px #FFFFFF, inset -2px -2px 0px 0px #404040, inset 2px 2px 0px 0px #DFDFDF !important;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
/* Selection */
|
| 56 |
-
::selection { background: #000080 !important; color: #FFFFFF !important; }
|
| 57 |
-
|
| 58 |
-
/* Tabs */
|
| 59 |
-
.tabs { gap: 0 !important; }
|
| 60 |
-
.tab-container::after { display: none !important; }
|
| 61 |
-
.tabs button[role="tab"] {
|
| 62 |
-
background: #C0C0C0 !important;
|
| 63 |
-
border-radius: 0 !important;
|
| 64 |
-
box-shadow: inset 1px 1px 0px 0px #FFFFFF, inset -1px 0px 0px 0px #808080, inset 2px 2px 0px 0px #DFDFDF, inset -2px 0px 0px 0px #404040 !important;
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
/* Code highlighting - white text on navy */
|
| 68 |
-
.highlight, span.highlight, .code.highlight {
|
| 69 |
-
background: #000080 !important;
|
| 70 |
-
color: #FFFFFF !important;
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
pre span[style*="background"], code span[style*="background"] {
|
| 74 |
-
color: #FFFFFF !important;
|
| 75 |
-
}
|
| 76 |
-
"""
|
| 77 |
|
| 78 |
with gr.Blocks() as demo:
|
| 79 |
-
with gr.Row(
|
| 80 |
-
with gr.Column(
|
| 81 |
-
gr.Markdown(
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
"""
|
| 88 |
)
|
| 89 |
-
with gr.Column(scale=3):
|
| 90 |
-
with gr.Group():
|
| 91 |
-
dropdown.render()
|
| 92 |
-
toggle_dark = gr.Button(value="Toggle Dark")
|
| 93 |
-
|
| 94 |
-
dropdown.change(None, dropdown, None, js=js)
|
| 95 |
-
toggle_dark.click(
|
| 96 |
-
None,
|
| 97 |
-
js="""
|
| 98 |
-
() => {
|
| 99 |
-
document.body.classList.toggle('dark');
|
| 100 |
-
}
|
| 101 |
-
""",
|
| 102 |
-
)
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
)
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
info="
|
| 124 |
)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
| 132 |
)
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
"
|
| 137 |
-
|
| 138 |
-
|
| 139 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
with gr.Row():
|
| 141 |
-
|
| 142 |
-
clear_btn = gr.Button("
|
|
|
|
| 143 |
|
| 144 |
-
|
| 145 |
-
time.sleep(3)
|
| 146 |
-
return "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg"
|
| 147 |
|
| 148 |
-
|
|
|
|
|
|
|
| 149 |
|
| 150 |
-
|
| 151 |
-
time.sleep(0.2)
|
| 152 |
|
| 153 |
-
|
| 154 |
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
-
with gr.
|
| 161 |
-
gr.
|
| 162 |
-
gr.
|
| 163 |
-
|
| 164 |
)
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
with gr.Row():
|
| 168 |
-
gr.ColorPicker()
|
| 169 |
-
gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
|
| 170 |
-
gr.Gallery(
|
| 171 |
-
[
|
| 172 |
-
(
|
| 173 |
-
"https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
|
| 174 |
-
"lion",
|
| 175 |
-
),
|
| 176 |
-
(
|
| 177 |
-
"https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
|
| 178 |
-
"logo",
|
| 179 |
-
),
|
| 180 |
-
(
|
| 181 |
-
"https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
|
| 182 |
-
"tower",
|
| 183 |
-
),
|
| 184 |
-
],
|
| 185 |
-
height=200,
|
| 186 |
)
|
| 187 |
|
| 188 |
-
with gr.
|
| 189 |
-
with gr.
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
|
| 216 |
if __name__ == "__main__":
|
| 217 |
-
demo.
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from windows95 import Windows95, WINDOWS_95_CSS
|
| 3 |
+
|
| 4 |
+
# Windows 95 Theme Demo
|
| 5 |
+
# This demo showcases the nostalgic Windows 95-inspired theme
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
with gr.Blocks() as demo:
|
| 8 |
+
with gr.Row():
|
| 9 |
+
with gr.Column():
|
| 10 |
+
gr.Markdown("## Input Controls")
|
| 11 |
+
|
| 12 |
+
name_input = gr.Textbox(
|
| 13 |
+
label="Your Name",
|
| 14 |
+
placeholder="Enter your name here...",
|
| 15 |
+
info="Type your name in this text field",
|
|
|
|
| 16 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
message_input = gr.Textbox(
|
| 19 |
+
label="Message",
|
| 20 |
+
placeholder="Type a message...",
|
| 21 |
+
lines=3,
|
| 22 |
+
info="Multi-line text input",
|
| 23 |
+
)
|
|
|
|
| 24 |
|
| 25 |
+
dropdown = gr.Dropdown(
|
| 26 |
+
label="Select Option",
|
| 27 |
+
choices=["Option 1", "Option 2", "Option 3"],
|
| 28 |
+
value="Option 1",
|
| 29 |
+
info="Choose from the dropdown menu",
|
| 30 |
+
)
|
| 31 |
|
| 32 |
+
slider = gr.Slider(
|
| 33 |
+
label="Volume",
|
| 34 |
+
minimum=0,
|
| 35 |
+
maximum=100,
|
| 36 |
+
value=50,
|
| 37 |
+
step=1,
|
| 38 |
+
info="Drag to adjust the value",
|
| 39 |
)
|
| 40 |
+
|
| 41 |
+
checkbox = gr.Checkbox(
|
| 42 |
+
label="Enable Feature", value=True, info="Toggle this setting"
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
radio = gr.Radio(
|
| 46 |
+
label="Choose One",
|
| 47 |
+
choices=["Small", "Medium", "Large"],
|
| 48 |
+
value="Medium",
|
| 49 |
+
info="Select a size",
|
| 50 |
)
|
| 51 |
+
|
| 52 |
+
checkboxgroup = gr.CheckboxGroup(
|
| 53 |
+
label="Select Multiple",
|
| 54 |
+
choices=["Red", "Green", "Blue"],
|
| 55 |
+
value=["Red"],
|
| 56 |
+
info="Pick your favorite colors",
|
| 57 |
)
|
| 58 |
+
|
| 59 |
+
with gr.Column():
|
| 60 |
+
gr.Markdown("## Output & Actions")
|
| 61 |
+
|
| 62 |
+
output_text = gr.Textbox(label="Output", interactive=False, lines=3)
|
| 63 |
+
|
| 64 |
with gr.Row():
|
| 65 |
+
submit_btn = gr.Button("OK", variant="primary")
|
| 66 |
+
clear_btn = gr.Button("Cancel", variant="stop")
|
| 67 |
+
secondary_btn = gr.Button("Help", variant="secondary")
|
| 68 |
|
| 69 |
+
gr.Markdown("## File Operations")
|
|
|
|
|
|
|
| 70 |
|
| 71 |
+
file_upload = gr.File(
|
| 72 |
+
label="Upload File", file_types=[".txt", ".csv", ".json"]
|
| 73 |
+
)
|
| 74 |
|
| 75 |
+
image_input = gr.Image(label="Image Preview", type="pil")
|
|
|
|
| 76 |
|
| 77 |
+
gr.Markdown("## Data Display")
|
| 78 |
|
| 79 |
+
dataframe = gr.Dataframe(
|
| 80 |
+
label="Data Table",
|
| 81 |
+
headers=["Name", "Value", "Status"],
|
| 82 |
+
datatype=["str", "number", "str"],
|
| 83 |
+
value=[
|
| 84 |
+
["Item 1", 100, "Active"],
|
| 85 |
+
["Item 2", 200, "Inactive"],
|
| 86 |
+
["Item 3", 300, "Pending"],
|
| 87 |
+
],
|
| 88 |
+
)
|
| 89 |
|
| 90 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 91 |
+
gr.Markdown("Additional configuration options would go here.")
|
| 92 |
+
adv_slider = gr.Slider(
|
| 93 |
+
label="Advanced Slider", minimum=0, maximum=100, value=25
|
| 94 |
)
|
| 95 |
+
adv_text = gr.Textbox(
|
| 96 |
+
label="Advanced Input", placeholder="Enter advanced settings..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
)
|
| 98 |
|
| 99 |
+
with gr.Tabs():
|
| 100 |
+
with gr.TabItem("Tab 1"):
|
| 101 |
+
gr.Markdown("Content for Tab 1")
|
| 102 |
+
gr.Textbox(label="Tab 1 Input")
|
| 103 |
+
with gr.TabItem("Tab 2"):
|
| 104 |
+
gr.Markdown("Content for Tab 2")
|
| 105 |
+
gr.Textbox(label="Tab 2 Input")
|
| 106 |
+
with gr.TabItem("Tab 3"):
|
| 107 |
+
gr.Markdown("Content for Tab 3")
|
| 108 |
+
gr.Textbox(label="Tab 3 Input")
|
| 109 |
+
|
| 110 |
+
# Event handlers
|
| 111 |
+
def process_input(name, message, dropdown, slider, checkbox, radio, colors):
|
| 112 |
+
result = f"Name: {name}\n"
|
| 113 |
+
result += f"Message: {message}\n"
|
| 114 |
+
result += f"Dropdown: {dropdown}\n"
|
| 115 |
+
result += f"Slider: {slider}\n"
|
| 116 |
+
result += f"Checkbox: {checkbox}\n"
|
| 117 |
+
result += f"Radio: {radio}\n"
|
| 118 |
+
result += f"Colors: {', '.join(colors)}"
|
| 119 |
+
return result
|
| 120 |
+
|
| 121 |
+
def clear_output():
|
| 122 |
+
return ""
|
| 123 |
+
|
| 124 |
+
submit_btn.click(
|
| 125 |
+
fn=process_input,
|
| 126 |
+
inputs=[
|
| 127 |
+
name_input,
|
| 128 |
+
message_input,
|
| 129 |
+
dropdown,
|
| 130 |
+
slider,
|
| 131 |
+
checkbox,
|
| 132 |
+
radio,
|
| 133 |
+
checkboxgroup,
|
| 134 |
+
],
|
| 135 |
+
outputs=output_text,
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
clear_btn.click(fn=clear_output, outputs=output_text)
|
| 139 |
|
| 140 |
|
| 141 |
if __name__ == "__main__":
|
| 142 |
+
demo.launch(theme=Windows95(), css=WINDOWS_95_CSS)
|