Update background and working version
Browse files- app.py +10 -7
- style_20250314.css +187 -0
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def load_data(query_params, model_3d):
|
|
|
|
| 4 |
model_url = query_params.get("3d", None) if query_params else None
|
| 5 |
hm_url = query_params.get("hm", None) if query_params else None
|
| 6 |
img_url = query_params.get("image", None) if query_params else None
|
|
@@ -10,11 +11,13 @@ def load_data(query_params, model_3d):
|
|
| 10 |
if img_url:
|
| 11 |
slider_images.append(img_url)
|
| 12 |
if not slider_images:
|
| 13 |
-
slider_images = ["images/
|
|
|
|
|
|
|
| 14 |
return model_url, slider_images
|
| 15 |
|
| 16 |
gr.set_static_paths(paths=["images/", "models/", "assets/"])
|
| 17 |
-
with gr.Blocks(theme=
|
| 18 |
gr.Markdown("# 3D Model Viewer")
|
| 19 |
|
| 20 |
with gr.Row():
|
|
@@ -25,7 +28,7 @@ with gr.Blocks(theme="Surn/Beeuty") as demo:
|
|
| 25 |
)
|
| 26 |
image_slider = gr.ImageSlider(
|
| 27 |
label="Images",
|
| 28 |
-
value=
|
| 29 |
height=400
|
| 30 |
)
|
| 31 |
|
|
@@ -36,9 +39,9 @@ with gr.Blocks(theme="Surn/Beeuty") as demo:
|
|
| 36 |
)
|
| 37 |
|
| 38 |
# Use JavaScript to pass the query parameters to your callback.
|
| 39 |
-
|
| 40 |
load_data,
|
| 41 |
-
inputs=[gr.JSON(), model_3d],
|
| 42 |
outputs=[model_3d, image_slider],
|
| 43 |
js="""() => {
|
| 44 |
const params = Object.fromEntries(new URLSearchParams(window.location.search));
|
|
@@ -47,7 +50,7 @@ with gr.Blocks(theme="Surn/Beeuty") as demo:
|
|
| 47 |
)
|
| 48 |
|
| 49 |
if __name__ == "__main__":
|
| 50 |
-
|
| 51 |
allowed_paths=["assets", "assets/", "./assets", "images/", "./images", 'e:/TMP', 'models/'],
|
| 52 |
favicon_path="./assets/favicon.ico"
|
| 53 |
)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def load_data(query_params, model_3d, image_slider):
|
| 4 |
+
# set default values or pull from querystring
|
| 5 |
model_url = query_params.get("3d", None) if query_params else None
|
| 6 |
hm_url = query_params.get("hm", None) if query_params else None
|
| 7 |
img_url = query_params.get("image", None) if query_params else None
|
|
|
|
| 11 |
if img_url:
|
| 12 |
slider_images.append(img_url)
|
| 13 |
if not slider_images:
|
| 14 |
+
slider_images = ["images/beeuty_545jlbh1_v12_alpha96_300dpi.png", "images/beeuty_545jlbh1_v12_alpha96_300dpi_depth.png"]
|
| 15 |
+
if not model_url:
|
| 16 |
+
model_url = "models/beeuty_545jlbh1_300dpi.glb"
|
| 17 |
return model_url, slider_images
|
| 18 |
|
| 19 |
gr.set_static_paths(paths=["images/", "models/", "assets/"])
|
| 20 |
+
with gr.Blocks(css_paths="style_20250314.css", title="3D viewer", theme='Surn/Beeuty',delete_cache=(21600,86400)) as viewer3d:
|
| 21 |
gr.Markdown("# 3D Model Viewer")
|
| 22 |
|
| 23 |
with gr.Row():
|
|
|
|
| 28 |
)
|
| 29 |
image_slider = gr.ImageSlider(
|
| 30 |
label="Images",
|
| 31 |
+
value=None,
|
| 32 |
height=400
|
| 33 |
)
|
| 34 |
|
|
|
|
| 39 |
)
|
| 40 |
|
| 41 |
# Use JavaScript to pass the query parameters to your callback.
|
| 42 |
+
viewer3d.load(
|
| 43 |
load_data,
|
| 44 |
+
inputs=[gr.JSON(), model_3d, image_slider],
|
| 45 |
outputs=[model_3d, image_slider],
|
| 46 |
js="""() => {
|
| 47 |
const params = Object.fromEntries(new URLSearchParams(window.location.search));
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
if __name__ == "__main__":
|
| 53 |
+
viewer3d.launch(
|
| 54 |
allowed_paths=["assets", "assets/", "./assets", "images/", "./images", 'e:/TMP', 'models/'],
|
| 55 |
favicon_path="./assets/favicon.ico"
|
| 56 |
)
|
style_20250314.css
ADDED
|
@@ -0,0 +1,187 @@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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.interface-wrapper {
|
| 2 |
+
max-width: 1024px;
|
| 3 |
+
margin: 0 auto;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
.centered {
|
| 7 |
+
margin: 0 auto;
|
| 8 |
+
display: block;
|
| 9 |
+
text-align:center;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
.solid {
|
| 13 |
+
opacity: 1.0 !important;
|
| 14 |
+
height: auto !important;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
.intro {
|
| 18 |
+
font-size: 1.2em !important;
|
| 19 |
+
font-weight: bold;
|
| 20 |
+
text-align: center;
|
| 21 |
+
/*background-color: rgba(242, 218, 163, 0.62);*/
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.dark .gradio-container.gradio-container-5-23-3 .contain .intro .prose {
|
| 25 |
+
/*background-color: rgba(41, 18, 5, 0.38) !important;*/
|
| 26 |
+
}
|
| 27 |
+
.toast-body.info {
|
| 28 |
+
background-color: rgba(242, 218, 163, 0.75);
|
| 29 |
+
}
|
| 30 |
+
.dark .toast-body.info {
|
| 31 |
+
background-color: rgba(128, 128, 128, 0.75);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.small {
|
| 35 |
+
font-size: smaller !important;
|
| 36 |
+
text-align: center;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.imgcontainer img {
|
| 40 |
+
object-fit: contain !important;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
#examples {
|
| 44 |
+
font-weight: bolder;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
--background-fill-primary: #FBCE50 !important;
|
| 48 |
+
#col-container {
|
| 49 |
+
max-width: 1024px;
|
| 50 |
+
margin-left: auto;
|
| 51 |
+
margin-right: auto;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
a {
|
| 55 |
+
text-decoration-line: underline;
|
| 56 |
+
font-weight: 600;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
#btn-generate {
|
| 60 |
+
background-image: linear-gradient(to right bottom, rgb(157, 255, 157), rgb(229, 255, 235));
|
| 61 |
+
color: var(--primary-800);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
#btn-generate:hover {
|
| 65 |
+
background-image: linear-gradient(to right bottom, rgb(229, 255, 229), rgb(255, 255, 255));
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
#btn-generate:active {
|
| 69 |
+
background-image: linear-gradient(to right bottom, rgb(229, 255, 235), rgb(157, 255, 157));
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
#versions {
|
| 73 |
+
margin-top: 1em;
|
| 74 |
+
width: 100%;
|
| 75 |
+
text-align: center;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.small-btn {
|
| 79 |
+
max-width: 75px;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
#gallery .thumbnails, #lora_gallery .thumbnails {
|
| 83 |
+
flex-direction: column !important;
|
| 84 |
+
display: inline-flex !important;
|
| 85 |
+
flex-wrap: wrap !important;
|
| 86 |
+
position: relative !important;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
#gallery caption.caption, #lora_gallery caption.caption {
|
| 90 |
+
flex-direction: row !important;
|
| 91 |
+
display: inline-flex !important;
|
| 92 |
+
flex-wrap: wrap;
|
| 93 |
+
white-space: unset !important;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
#gallery .image-button img.with-caption, #lora_gallery .image-button img.with-caption {
|
| 97 |
+
object-fit: cover !important;
|
| 98 |
+
object-position: center !important;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
#gallery button.preview, #lora_gallery button.preview {
|
| 102 |
+
position: relative !important;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.gradio-container::before {
|
| 106 |
+
content: ' ';
|
| 107 |
+
display: block;
|
| 108 |
+
position: absolute;
|
| 109 |
+
left: 0;
|
| 110 |
+
top: 0;
|
| 111 |
+
width: 100%;
|
| 112 |
+
height: 100%;
|
| 113 |
+
opacity: 0.25;
|
| 114 |
+
background-image: url('gradio_api/file=./images/logo.png');
|
| 115 |
+
background-repeat: no-repeat;
|
| 116 |
+
background-position: 50% 0;
|
| 117 |
+
background-size: contain;
|
| 118 |
+
background-color: rgba(0,0,0,0.9);
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
#component-0, #component-1 {
|
| 122 |
+
opacity: 0.9;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
#excluded_colors {
|
| 126 |
+
width: 95%;
|
| 127 |
+
margin: 0 auto;
|
| 128 |
+
font-size: smaller;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
@media only screen and (min-width: 1920px) {
|
| 132 |
+
.gradio-container, .gradio-container::before {
|
| 133 |
+
max-width: 1920px !important;
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.sidebar .toggle-button::before {
|
| 138 |
+
content: 'Sketch Pad';
|
| 139 |
+
font-weight: bold;
|
| 140 |
+
transform: rotate(180deg);
|
| 141 |
+
margin-right: -120px;
|
| 142 |
+
width: 120px;
|
| 143 |
+
background-color: rgba(242, 218, 163, 0.62);
|
| 144 |
+
}
|
| 145 |
+
.dark .sidebar .toggle-button::before {
|
| 146 |
+
background-color: rgba(41, 18, 5, 0.38) !important;
|
| 147 |
+
}
|
| 148 |
+
.sidebar.open .toggle-button::before {
|
| 149 |
+
content: '';
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
#sketchpd, #filters, #image_gen, #accordian_3d {
|
| 153 |
+
outline-color: #bbf7d0;
|
| 154 |
+
outline-style:solid;
|
| 155 |
+
outline-width: 1px;
|
| 156 |
+
outline-offset: 1px;
|
| 157 |
+
padding: 2px;
|
| 158 |
+
border-radius:6px;
|
| 159 |
+
}
|
| 160 |
+
.outline-important {
|
| 161 |
+
outline-color: var(--accordion-text-color);
|
| 162 |
+
outline-style: solid;
|
| 163 |
+
outline-width: 2px;
|
| 164 |
+
outline-offset: 2px;
|
| 165 |
+
padding: 2px;
|
| 166 |
+
border-radius: 6px;
|
| 167 |
+
}
|
| 168 |
+
.selected.svelte-1tcem6n.svelte-1tcem6n {
|
| 169 |
+
font-size: large;
|
| 170 |
+
font-weight: bold;
|
| 171 |
+
color: var(--body-text-color);
|
| 172 |
+
}
|
| 173 |
+
.tab-wrapper.svelte-1tcem6n.svelte-1tcem6n {
|
| 174 |
+
height: var(--size-12);
|
| 175 |
+
padding-bottom: var(--size-1);
|
| 176 |
+
text-align: center;
|
| 177 |
+
background-blend-mode: multiply;
|
| 178 |
+
border-radius: var(--block-radius);
|
| 179 |
+
background-color: var(--block-background-fill);
|
| 180 |
+
|
| 181 |
+
outline-color: var(--accordion-text-color);
|
| 182 |
+
outline-style: solid;
|
| 183 |
+
outline-width: 2px;
|
| 184 |
+
outline-offset: 2px;
|
| 185 |
+
padding: 2px;
|
| 186 |
+
border-radius: 6px;
|
| 187 |
+
}
|