prithivMLmods commited on
Commit
b56a55c
·
verified ·
1 Parent(s): 6439477

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -33
app.py CHANGED
@@ -88,7 +88,7 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
88
  pipe = QwenImageEditPlusPipeline.from_pretrained(
89
  "Qwen/Qwen-Image-Edit-2511",
90
  transformer=QwenImageTransformer2DModel.from_pretrained(
91
- "prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V19",
92
  torch_dtype=dtype,
93
  device_map='cuda'
94
  ),
@@ -246,14 +246,11 @@ class LightingControl3D(gr.HTML):
246
  const scene = new THREE.Scene();
247
  scene.background = new THREE.Color(0x1a1a1a);
248
 
249
- // Add subtle fog to enhance the volumetric look
250
- scene.fog = new THREE.FogExp2(0x1a1a1a, 0.05);
251
-
252
  const camera = new THREE.PerspectiveCamera(50, wrapper.clientWidth / wrapper.clientHeight, 0.1, 1000);
253
  camera.position.set(4.5, 3, 4.5);
254
  camera.lookAt(0, 0.75, 0);
255
 
256
- const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
257
  renderer.setSize(wrapper.clientWidth, wrapper.clientHeight);
258
  renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
259
  renderer.shadowMap.enabled = true;
@@ -261,13 +258,12 @@ class LightingControl3D(gr.HTML):
261
  wrapper.insertBefore(renderer.domElement, promptOverlay);
262
 
263
  // Lighting for the scene
264
- const ambientLight = new THREE.AmbientLight(0xffffff, 0.2);
265
- scene.add(ambientLight);
266
 
267
  // Ground plane for shadows
268
  const ground = new THREE.Mesh(
269
  new THREE.PlaneGeometry(10, 10),
270
- new THREE.ShadowMaterial({ opacity: 0.5 }) // Darker shadow for contrast
271
  );
272
  ground.rotation.x = -Math.PI / 2;
273
  ground.position.y = 0;
@@ -389,7 +385,7 @@ class LightingControl3D(gr.HTML):
389
  updateTextureFromUrl(props.imageUrl);
390
  }
391
 
392
- // --- NEW LIGHT MODEL: SOFTBOX WITH VOLUMETRIC RAYS ---
393
  const lightGroup = new THREE.Group();
394
 
395
  // 1. Softbox Housing (Red)
@@ -406,7 +402,7 @@ class LightingControl3D(gr.HTML):
406
  const diffuserMat = new THREE.MeshStandardMaterial({
407
  color: 0xffffff, // WHITE LIGHT
408
  emissive: 0xffffff,
409
- emissiveIntensity: 3.0, // Brighter for ray visibility
410
  roughness: 0.2
411
  });
412
  const diffuser = new THREE.Mesh(diffuserGeo, diffuserMat);
@@ -414,37 +410,17 @@ class LightingControl3D(gr.HTML):
414
 
415
  // Assemble the softbox
416
  housing.add(diffuser);
417
-
418
- // 3. Volumetric Ray Mesh (Cone)
419
- // Creates a visible beam of light
420
- const rayLength = 4.0;
421
- const rayGeo = new THREE.ConeGeometry(0.8, rayLength, 32, 1, true); // Open ended cone
422
- // Rotate cone so it points along Z-axis like the light
423
- rayGeo.rotateX(Math.PI / 2);
424
- rayGeo.translate(0, 0, rayLength / 2 + 0.2); // Move it to start at the diffuser
425
-
426
- const rayMat = new THREE.MeshBasicMaterial({
427
- color: 0xffffff,
428
- transparent: true,
429
- opacity: 0.08, // Subtle transparency
430
- side: THREE.FrontSide,
431
- depthWrite: false, // Don't block other objects
432
- blending: THREE.AdditiveBlending // Glow effect
433
- });
434
- const rayCone = new THREE.Mesh(rayGeo, rayMat);
435
- housing.add(rayCone);
436
-
437
  lightGroup.add(housing);
438
 
439
  // Actual Light Source
440
- const spotLight = new THREE.SpotLight(0xffffff, 20, 10, Math.PI / 4, 0.5, 1);
441
- spotLight.position.set(0, 0, 0.1);
442
  spotLight.castShadow = true;
443
  spotLight.shadow.mapSize.width = 1024;
444
  spotLight.shadow.mapSize.height = 1024;
445
  spotLight.shadow.camera.near = 0.5;
446
  spotLight.shadow.camera.far = 500;
447
- spotLight.shadow.bias = -0.0001;
448
  lightGroup.add(spotLight);
449
 
450
  const lightTarget = new THREE.Object3D();
 
88
  pipe = QwenImageEditPlusPipeline.from_pretrained(
89
  "Qwen/Qwen-Image-Edit-2511",
90
  transformer=QwenImageTransformer2DModel.from_pretrained(
91
+ "prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V4",
92
  torch_dtype=dtype,
93
  device_map='cuda'
94
  ),
 
246
  const scene = new THREE.Scene();
247
  scene.background = new THREE.Color(0x1a1a1a);
248
 
 
 
 
249
  const camera = new THREE.PerspectiveCamera(50, wrapper.clientWidth / wrapper.clientHeight, 0.1, 1000);
250
  camera.position.set(4.5, 3, 4.5);
251
  camera.lookAt(0, 0.75, 0);
252
 
253
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
254
  renderer.setSize(wrapper.clientWidth, wrapper.clientHeight);
255
  renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
256
  renderer.shadowMap.enabled = true;
 
258
  wrapper.insertBefore(renderer.domElement, promptOverlay);
259
 
260
  // Lighting for the scene
261
+ scene.add(new THREE.AmbientLight(0xffffff, 0.1));
 
262
 
263
  // Ground plane for shadows
264
  const ground = new THREE.Mesh(
265
  new THREE.PlaneGeometry(10, 10),
266
+ new THREE.ShadowMaterial({ opacity: 0.3 })
267
  );
268
  ground.rotation.x = -Math.PI / 2;
269
  ground.position.y = 0;
 
385
  updateTextureFromUrl(props.imageUrl);
386
  }
387
 
388
+ // --- NEW LIGHT MODEL: SOFTBOX ---
389
  const lightGroup = new THREE.Group();
390
 
391
  // 1. Softbox Housing (Red)
 
402
  const diffuserMat = new THREE.MeshStandardMaterial({
403
  color: 0xffffff, // WHITE LIGHT
404
  emissive: 0xffffff,
405
+ emissiveIntensity: 2.0,
406
  roughness: 0.2
407
  });
408
  const diffuser = new THREE.Mesh(diffuserGeo, diffuserMat);
 
410
 
411
  // Assemble the softbox
412
  housing.add(diffuser);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  lightGroup.add(housing);
414
 
415
  // Actual Light Source
416
+ const spotLight = new THREE.SpotLight(0xffffff, 10, 10, Math.PI / 3, 1, 1);
417
+ spotLight.position.set(0, 0, -0.05);
418
  spotLight.castShadow = true;
419
  spotLight.shadow.mapSize.width = 1024;
420
  spotLight.shadow.mapSize.height = 1024;
421
  spotLight.shadow.camera.near = 0.5;
422
  spotLight.shadow.camera.far = 500;
423
+ spotLight.shadow.bias = -0.005;
424
  lightGroup.add(spotLight);
425
 
426
  const lightTarget = new THREE.Object3D();