Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,39 @@ import torch
|
|
| 22 |
import json
|
| 23 |
from langdetect import detect
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# Load model and processor
|
| 26 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 27 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base").to("cpu")
|
|
@@ -468,10 +501,19 @@ window.addEventListener("beforeunload", async function (e) {
|
|
| 468 |
return f"Deleted {count} chat file(s)."
|
| 469 |
except Exception as e:
|
| 470 |
return f"Error: {e}"
|
| 471 |
-
|
| 472 |
clear_button.click(fn=clear_all_chats, inputs=[], outputs=clear_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
|
| 474 |
-
|
|
|
|
| 475 |
with gr.Tab("AI Image Generator"):
|
| 476 |
gr.Markdown("## Free Stable Diffusion Image Generator (CPU)")
|
| 477 |
prompt = gr.Textbox(label="Enter a prompt")
|
|
|
|
| 22 |
import json
|
| 23 |
from langdetect import detect
|
| 24 |
|
| 25 |
+
THEMES = {
|
| 26 |
+
"Default": "",
|
| 27 |
+
"Neon": """
|
| 28 |
+
* {
|
| 29 |
+
background-color: #0f0f0f;
|
| 30 |
+
color: #39ff14;
|
| 31 |
+
}
|
| 32 |
+
.gr-button {
|
| 33 |
+
background-color: #39ff14 !important;
|
| 34 |
+
color: #0f0f0f !important;
|
| 35 |
+
}
|
| 36 |
+
""",
|
| 37 |
+
"Hacker": """
|
| 38 |
+
* {
|
| 39 |
+
background-color: #000000;
|
| 40 |
+
color: #00ff00;
|
| 41 |
+
font-family: 'Courier New', monospace;
|
| 42 |
+
}
|
| 43 |
+
""",
|
| 44 |
+
"Solarized Light": """
|
| 45 |
+
* {
|
| 46 |
+
background-color: #fdf6e3;
|
| 47 |
+
color: #657b83;
|
| 48 |
+
}
|
| 49 |
+
""",
|
| 50 |
+
"Dark Mode": """
|
| 51 |
+
* {
|
| 52 |
+
background-color: #1e1e1e;
|
| 53 |
+
color: #c7c7c7;
|
| 54 |
+
}
|
| 55 |
+
"""
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
# Load model and processor
|
| 59 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 60 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base").to("cpu")
|
|
|
|
| 501 |
return f"Deleted {count} chat file(s)."
|
| 502 |
except Exception as e:
|
| 503 |
return f"Error: {e}"
|
| 504 |
+
|
| 505 |
clear_button.click(fn=clear_all_chats, inputs=[], outputs=clear_output)
|
| 506 |
+
theme_selector = gr.Dropdown(
|
| 507 |
+
label="Select Theme",
|
| 508 |
+
choices=list(THEMES.keys()),
|
| 509 |
+
value="Default"
|
| 510 |
+
)
|
| 511 |
+
apply_button = gr.Button("Apply Theme")
|
| 512 |
+
def apply_theme(selected):
|
| 513 |
+
return gr.update(css=THEMES.get(selected, ""))
|
| 514 |
|
| 515 |
+
apply_button.click(fn=apply_theme, inputs=theme_selector, outputs=None)
|
| 516 |
+
|
| 517 |
with gr.Tab("AI Image Generator"):
|
| 518 |
gr.Markdown("## Free Stable Diffusion Image Generator (CPU)")
|
| 519 |
prompt = gr.Textbox(label="Enter a prompt")
|