Spaces:
Running on Zero
Running on Zero
bolajiev commited on
Commit ·
c3d2108
1
Parent(s): c1ec90c
Block 0+2+3: 3B model, curated examples, glow 1.0, auto-frame camera, brighter lights
Browse files
app.py
CHANGED
|
@@ -40,12 +40,14 @@ def _generate_json(prompt: str) -> str:
|
|
| 40 |
|
| 41 |
|
| 42 |
EXAMPLES = [
|
| 43 |
-
"
|
| 44 |
-
"a
|
| 45 |
-
"
|
| 46 |
-
"
|
| 47 |
-
"
|
| 48 |
-
"
|
|
|
|
|
|
|
| 49 |
]
|
| 50 |
|
| 51 |
|
|
@@ -100,7 +102,7 @@ with gr.Blocks(title="ThreeGen", theme=gr.themes.Soft()) as demo:
|
|
| 100 |
btn = gr.Button("Generate", variant="primary")
|
| 101 |
with gr.Row():
|
| 102 |
glow = gr.Checkbox(label="Glow", value=True)
|
| 103 |
-
glow_strength = gr.Slider(0.0, 2.0, value=
|
| 104 |
with gr.Row():
|
| 105 |
style = gr.Dropdown(
|
| 106 |
["realistic", "flat", "wireframe", "toon"],
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
EXAMPLES = [
|
| 43 |
+
"a faceted crystal — one large icosahedron, electric blue, metallic",
|
| 44 |
+
"a glowing wireframe torus knot on a black background",
|
| 45 |
+
"a chunky cartoon mushroom: red dome sphere on a white cylinder stem",
|
| 46 |
+
"a molten-gold torus knot, high metalness, low roughness",
|
| 47 |
+
"three glowing neon-green cubes stacked into a tower",
|
| 48 |
+
"a chrome icosahedron orbited by small glowing purple spheres",
|
| 49 |
+
"a single low-poly diamond, cyan, slowly rotating",
|
| 50 |
+
"a red wireframe sphere inside a larger blue wireframe sphere",
|
| 51 |
]
|
| 52 |
|
| 53 |
|
|
|
|
| 102 |
btn = gr.Button("Generate", variant="primary")
|
| 103 |
with gr.Row():
|
| 104 |
glow = gr.Checkbox(label="Glow", value=True)
|
| 105 |
+
glow_strength = gr.Slider(0.0, 2.0, value=1.0, step=0.1, label="Glow strength")
|
| 106 |
with gr.Row():
|
| 107 |
style = gr.Dropdown(
|
| 108 |
["realistic", "flat", "wireframe", "toon"],
|
compiler.py
CHANGED
|
@@ -168,6 +168,24 @@ TEMPLATE = """<!DOCTYPE html>
|
|
| 168 |
// ---- objects ----
|
| 169 |
__OBJECTS__
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
// ---- bloom post-processing ----
|
| 172 |
const USE_BLOOM = __USE_BLOOM__;
|
| 173 |
const BLOOM_STRENGTH = __BLOOM_STRENGTH__;
|
|
|
|
| 168 |
// ---- objects ----
|
| 169 |
__OBJECTS__
|
| 170 |
|
| 171 |
+
// ---- auto-frame camera to scene ----
|
| 172 |
+
const box = new THREE.Box3().setFromObject(group);
|
| 173 |
+
if (!box.isEmpty()) {
|
| 174 |
+
const size = box.getSize(new THREE.Vector3());
|
| 175 |
+
const center = box.getCenter(new THREE.Vector3());
|
| 176 |
+
const maxDim = Math.max(size.x, size.y, size.z) || 1;
|
| 177 |
+
const fov = camera.fov * (Math.PI / 180);
|
| 178 |
+
const dist = (maxDim / 2) / Math.tan(fov / 2) * 1.6;
|
| 179 |
+
camera.position.set(center.x + dist * 0.7,
|
| 180 |
+
center.y + dist * 0.45,
|
| 181 |
+
center.z + dist);
|
| 182 |
+
camera.near = dist / 100;
|
| 183 |
+
camera.far = dist * 100;
|
| 184 |
+
camera.updateProjectionMatrix();
|
| 185 |
+
controls.target.copy(center);
|
| 186 |
+
controls.update();
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
// ---- bloom post-processing ----
|
| 190 |
const USE_BLOOM = __USE_BLOOM__;
|
| 191 |
const BLOOM_STRENGTH = __BLOOM_STRENGTH__;
|
llm.py
CHANGED
|
@@ -16,7 +16,7 @@ import logging
|
|
| 16 |
import os
|
| 17 |
import threading
|
| 18 |
|
| 19 |
-
MODEL_ID = os.environ.get("MODEL_ID", "Qwen/Qwen2.5-Coder-
|
| 20 |
MAX_PROMPT_CHARS = int(os.environ.get("MAX_PROMPT_CHARS", "500"))
|
| 21 |
|
| 22 |
log = logging.getLogger(__name__)
|
|
|
|
| 16 |
import os
|
| 17 |
import threading
|
| 18 |
|
| 19 |
+
MODEL_ID = os.environ.get("MODEL_ID", "Qwen/Qwen2.5-Coder-3B-Instruct")
|
| 20 |
MAX_PROMPT_CHARS = int(os.environ.get("MAX_PROMPT_CHARS", "500"))
|
| 21 |
|
| 22 |
log = logging.getLogger(__name__)
|
scene.py
CHANGED
|
@@ -210,6 +210,6 @@ def build_scene(data: Optional[dict]) -> Scene:
|
|
| 210 |
log.warning("build_scene: no lights, inserting defaults")
|
| 211 |
scene.lights = [
|
| 212 |
Light(type="ambient", intensity=0.5),
|
| 213 |
-
Light(type="directional", intensity=1.
|
| 214 |
]
|
| 215 |
return scene
|
|
|
|
| 210 |
log.warning("build_scene: no lights, inserting defaults")
|
| 211 |
scene.lights = [
|
| 212 |
Light(type="ambient", intensity=0.5),
|
| 213 |
+
Light(type="directional", intensity=1.3, position=[5, 8, 6]),
|
| 214 |
]
|
| 215 |
return scene
|