Spaces:
Configuration error
Configuration error
Add base64 encoding for background image in app.py and update CSS for dynamic background styling.
Browse files
app.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Configuration
|
| 6 |
LOCAL_MODELS = ["jakeboggs/MTG-Llama", "microsoft/Phi-3-mini-4k-instruct"]
|
|
@@ -17,26 +19,33 @@ for model in API_MODELS:
|
|
| 17 |
pipe = None
|
| 18 |
stop_inference = False
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# Fancy styling
|
| 21 |
-
fancy_css = """
|
| 22 |
-
body {
|
| 23 |
-
background-image: url('
|
| 24 |
background-repeat: repeat;
|
| 25 |
background-size: auto;
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
font-family: 'Arial', sans-serif;
|
| 30 |
-
}
|
| 31 |
-
.gradio-container {
|
| 32 |
max-width: 700px;
|
| 33 |
margin: 0 auto;
|
| 34 |
padding: 20px;
|
| 35 |
-
background-color: transparent;
|
| 36 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 37 |
border-radius: 10px;
|
| 38 |
-
|
| 39 |
-
|
|
|
|
| 40 |
background-color: #4CAF50;
|
| 41 |
color: white;
|
| 42 |
border: none;
|
|
@@ -44,22 +53,22 @@ fancy_css = """
|
|
| 44 |
padding: 10px 20px;
|
| 45 |
cursor: pointer;
|
| 46 |
transition: background-color 0.3s ease;
|
| 47 |
-
}
|
| 48 |
-
.gr-button:hover {
|
| 49 |
background-color: #45a049;
|
| 50 |
-
}
|
| 51 |
-
.gr-slider input {
|
| 52 |
color: #4CAF50;
|
| 53 |
-
}
|
| 54 |
-
.gr-chat {
|
| 55 |
font-size: 16px;
|
| 56 |
-
}
|
| 57 |
-
#title {
|
| 58 |
text-align: center;
|
| 59 |
font-size: 2em;
|
| 60 |
margin-bottom: 20px;
|
| 61 |
color: #333;
|
| 62 |
-
}
|
| 63 |
"""
|
| 64 |
|
| 65 |
def respond(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import os
|
| 4 |
+
import base64
|
| 5 |
+
from pathlib import Path
|
| 6 |
|
| 7 |
# Configuration
|
| 8 |
LOCAL_MODELS = ["jakeboggs/MTG-Llama", "microsoft/Phi-3-mini-4k-instruct"]
|
|
|
|
| 19 |
pipe = None
|
| 20 |
stop_inference = False
|
| 21 |
|
| 22 |
+
ASSETS_DIR = Path(__file__).parent / "assets"
|
| 23 |
+
BACKGROUND_IMAGE_PATH = ASSETS_DIR / "confidant_pattern.png"
|
| 24 |
+
try:
|
| 25 |
+
with open(BACKGROUND_IMAGE_PATH, "rb") as _img_f:
|
| 26 |
+
_encoded_img = base64.b64encode(_img_f.read()).decode("ascii")
|
| 27 |
+
BACKGROUND_DATA_URL = f"data:image/png;base64,{_encoded_img}"
|
| 28 |
+
except Exception:
|
| 29 |
+
BACKGROUND_DATA_URL = ""
|
| 30 |
+
|
| 31 |
# Fancy styling
|
| 32 |
+
fancy_css = f"""
|
| 33 |
+
html, body, #root, .gradio-container {{
|
| 34 |
+
background-image: url('{BACKGROUND_DATA_URL}');
|
| 35 |
background-repeat: repeat;
|
| 36 |
background-size: auto;
|
| 37 |
+
background-color: transparent !important;
|
| 38 |
+
}}
|
| 39 |
+
.gradio-container {{
|
|
|
|
|
|
|
|
|
|
| 40 |
max-width: 700px;
|
| 41 |
margin: 0 auto;
|
| 42 |
padding: 20px;
|
| 43 |
+
background-color: transparent !important;
|
| 44 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 45 |
border-radius: 10px;
|
| 46 |
+
font-family: 'Arial', sans-serif;
|
| 47 |
+
}}
|
| 48 |
+
.gr-button {{
|
| 49 |
background-color: #4CAF50;
|
| 50 |
color: white;
|
| 51 |
border: none;
|
|
|
|
| 53 |
padding: 10px 20px;
|
| 54 |
cursor: pointer;
|
| 55 |
transition: background-color 0.3s ease;
|
| 56 |
+
}}
|
| 57 |
+
.gr-button:hover {{
|
| 58 |
background-color: #45a049;
|
| 59 |
+
}}
|
| 60 |
+
.gr-slider input {{
|
| 61 |
color: #4CAF50;
|
| 62 |
+
}}
|
| 63 |
+
.gr-chat {{
|
| 64 |
font-size: 16px;
|
| 65 |
+
}}
|
| 66 |
+
#title {{
|
| 67 |
text-align: center;
|
| 68 |
font-size: 2em;
|
| 69 |
margin-bottom: 20px;
|
| 70 |
color: #333;
|
| 71 |
+
}}
|
| 72 |
"""
|
| 73 |
|
| 74 |
def respond(
|