Spaces:
Running
Running
Upload 6 files
Browse files- .gitattributes +2 -0
- STScI-01G8H1NK4W8CJYHF2DDFD1W0DQ.png +3 -0
- app (31).py +418 -0
- ear0xuu2.jpg +3 -0
- mar0kuu2 (1).jpg +0 -0
- packages (1).txt +2 -0
- requirements (20).txt +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
ear0xuu2.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
STScI-01G8H1NK4W8CJYHF2DDFD1W0DQ.png filter=lfs diff=lfs merge=lfs -text
|
STScI-01G8H1NK4W8CJYHF2DDFD1W0DQ.png
ADDED
![]() |
Git LFS Details
|
app (31).py
ADDED
@@ -0,0 +1,418 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import bpy
|
2 |
+
import gradio as gr
|
3 |
+
import math
|
4 |
+
import os
|
5 |
+
import random
|
6 |
+
from diffusers.utils import load_image
|
7 |
+
from PIL import Image
|
8 |
+
import PIL.Image
|
9 |
+
##from io_scene_gltf2.blender.exp import gltf2_blender_export
|
10 |
+
|
11 |
+
os.putenv("XDG_RUNTIME_DIR", '.')
|
12 |
+
fin_rend = './rendered_scene.png'
|
13 |
+
fin_pth = './path_to_exp.blend'
|
14 |
+
fin_blend = './exp_scene.blend'
|
15 |
+
fin_obj = './exp_scene.obj'
|
16 |
+
fin_glb = './exp_scene.glb'
|
17 |
+
fin_gltf = './exp_scene.gltf'
|
18 |
+
fin_anim = './animation.mp4'
|
19 |
+
img = bpy.data.images.load('./STScI-01G8H1NK4W8CJYHF2DDFD1W0DQ.png')
|
20 |
+
earth_texture = bpy.data.images.load('./ear0xuu2.jpg')
|
21 |
+
mars_texture = bpy.data.images.load('mar0kuu2.jpg')
|
22 |
+
apol=[]
|
23 |
+
|
24 |
+
def add_planet(name, radius, mass, distance_from_sun):
|
25 |
+
material = bpy.data.materials.new(name="Mymarsmat"+str(random.randint(1,36)))
|
26 |
+
##material = bpy.data.materials.new(name="MyMaterial")
|
27 |
+
material.use_nodes = True
|
28 |
+
|
29 |
+
##for node in material.node_tree.nodes:
|
30 |
+
## material.node_tree.nodes.remove(node)
|
31 |
+
|
32 |
+
|
33 |
+
image_texture_node = material.node_tree.nodes.new('ShaderNodeTexImage')
|
34 |
+
if name=="mars":
|
35 |
+
image_texture_node.image = bpy.data.images.load("mar0kuu2.jpg")
|
36 |
+
else:
|
37 |
+
image_texture_node.image = bpy.data.images.load("ear0xuu2.jpg")
|
38 |
+
|
39 |
+
# Link the image texture node to the principled shader
|
40 |
+
bsdf_node = material.node_tree.nodes.get('Principled BSDF')
|
41 |
+
material.node_tree.links.new(bsdf_node.inputs['Base Color'], image_texture_node.outputs['Color'])
|
42 |
+
|
43 |
+
|
44 |
+
bpy.ops.mesh.primitive_uv_sphere_add(radius=radius, location=(distance_from_sun * random.uniform(-8, 8), random.uniform(-8, 8), random.uniform(-8, 3)))
|
45 |
+
planet = bpy.context.active_object
|
46 |
+
planet.name = name
|
47 |
+
##planet_material = bpy.data.materials.new(name=name + "_texture")
|
48 |
+
planet.data.materials.append(material)
|
49 |
+
planet["mass"] = mass
|
50 |
+
return planet
|
51 |
+
|
52 |
+
def visualize_planets():
|
53 |
+
bpy.ops.object.select_all(action='DESELECT')
|
54 |
+
for obj in bpy.context.scene.objects:
|
55 |
+
if obj.type == 'MESH' and "mass" in obj:
|
56 |
+
obj.select_set(True)
|
57 |
+
bpy.ops.view3d.snap_cursor_to_selected()
|
58 |
+
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
|
59 |
+
bpy.context.scene.cursor.location = (0, 0, 0)
|
60 |
+
|
61 |
+
##visualize_planets()
|
62 |
+
|
63 |
+
def create_planet_flyby_animation(planet, radius, duration):
|
64 |
+
bpy.context.view_layer.objects.active = planet
|
65 |
+
planet.select_set(True)
|
66 |
+
planet.animation_data_create()
|
67 |
+
planet.animation_data.action = bpy.data.actions.new(name="OrbitAction")
|
68 |
+
start_frame = 1
|
69 |
+
end_frame = int(duration * 10)
|
70 |
+
for frame in range(start_frame, end_frame + 1):
|
71 |
+
angle = (frame / end_frame) * 2 * math.pi
|
72 |
+
x = radius * math.cos(angle)
|
73 |
+
y = radius * math.sin(angle)
|
74 |
+
z = planet.location.z # Maintain the planet's z-coordinate
|
75 |
+
planet.location = (x, y, z)
|
76 |
+
planet.keyframe_insert(data_path="location", index=-1, frame=frame)
|
77 |
+
|
78 |
+
##create_planet_flyby_animation(planet, radius, 2)
|
79 |
+
|
80 |
+
def add_animated_space_rocks():
|
81 |
+
bpy.context.scene.render.fps = 10
|
82 |
+
duration = 2
|
83 |
+
for i in range(30):
|
84 |
+
bpy.ops.mesh.primitive_uv_sphere_add(radius=random.uniform(0.01, 0.1), location=(random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-4, 9)))
|
85 |
+
space_rock = bpy.context.active_object
|
86 |
+
space_rock.keyframe_insert(data_path="location", frame=1)
|
87 |
+
space_rock.location = (random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10))
|
88 |
+
space_rock.keyframe_insert(data_path="location", frame=duration * bpy.context.scene.render.fps)
|
89 |
+
|
90 |
+
def create_particle_effects_animation():
|
91 |
+
bpy.context.scene.render.fps = 10
|
92 |
+
duration = 2
|
93 |
+
|
94 |
+
bpy.ops.mesh.primitive_uv_sphere_add(radius=random.uniform(0.05, 0.10), location=(random.uniform(-1, 1), random.uniform(-1, 1), 1))
|
95 |
+
emitter = bpy.context.active_object
|
96 |
+
emitter.name = "ParticleEmitter"
|
97 |
+
|
98 |
+
particle_system = emitter.modifiers.new(name="ParticleSettings", type='PARTICLE_SYSTEM')
|
99 |
+
particle_system.particle_system.settings.count = 30
|
100 |
+
particle_system.particle_system.settings.frame_start = 1
|
101 |
+
particle_system.particle_system.settings.frame_end = duration * bpy.context.scene.render.fps
|
102 |
+
|
103 |
+
# Set the particle system to be rendered as an object
|
104 |
+
particle_system.particle_system.settings.render_type = 'OBJECT'
|
105 |
+
particle_system.particle_system.settings.instance_object = bpy.data.objects["ParticleOne"]
|
106 |
+
|
107 |
+
# Animate the emitter's location, rotation, and scale
|
108 |
+
emitter.keyframe_insert(data_path="location", index=-1, frame=1)
|
109 |
+
emitter.location = (random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10)) # Set the new location for the end of the animation
|
110 |
+
emitter.keyframe_insert(data_path="location", index=-1, frame=duration * bpy.context.scene.render.fps)
|
111 |
+
|
112 |
+
def create_meteor_with_particle_system():
|
113 |
+
# Create a mesh object to serve as the meteor
|
114 |
+
bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=4, radius=0.25, location=(random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10)))
|
115 |
+
meteor = bpy.context.active_object
|
116 |
+
meteor.name = "Meteor"
|
117 |
+
meteor_material = bpy.data.materials.new(name="MeteorMaterial")
|
118 |
+
meteor.data.materials.append(meteor_material)
|
119 |
+
meteor.active_material.use_nodes = True
|
120 |
+
nodes = meteor.active_material.node_tree.nodes
|
121 |
+
emission_node = nodes.new(type='ShaderNodeEmission')
|
122 |
+
emission_node.inputs[0].default_value = (0.0, 0.0, 1.0, 1) # Blue color
|
123 |
+
output_node = nodes.get("Material Output")
|
124 |
+
material_link = meteor.active_material.node_tree.links.new
|
125 |
+
material_link(emission_node.outputs[0], output_node.inputs[0])
|
126 |
+
|
127 |
+
bpy.ops.mesh.primitive_uv_sphere_add(radius=random.uniform(0.01, 0.04), location=(random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10)))
|
128 |
+
partone = bpy.context.active_object
|
129 |
+
partone.name = "ParticleOne"
|
130 |
+
|
131 |
+
particle_settings = meteor.modifiers.new(name="EnergySpheres", type='PARTICLE_SYSTEM')
|
132 |
+
particle_settings.particle_system.settings.count = 100
|
133 |
+
particle_settings.particle_system.settings.lifetime = random.uniform(10, 20)
|
134 |
+
particle_settings.particle_system.settings.frame_start = 1
|
135 |
+
particle_settings.particle_system.settings.frame_end = 20
|
136 |
+
particle_settings.particle_system.settings.use_emit_random = True
|
137 |
+
particle_settings.particle_system.settings.render_type = 'OBJECT'
|
138 |
+
particle_settings.particle_system.settings.instance_object = bpy.data.objects["ParticleOne"]
|
139 |
+
|
140 |
+
meteor.keyframe_insert(data_path="location", index=-1, frame=1)
|
141 |
+
meteor.location = (random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10))
|
142 |
+
meteor.keyframe_insert(data_path="location", index=-1, frame=20)
|
143 |
+
|
144 |
+
def create_scene():
|
145 |
+
scene = bpy.context.scene
|
146 |
+
render = scene.render
|
147 |
+
render.resolution_x = 1920
|
148 |
+
render.resolution_y = 1080
|
149 |
+
render.engine = 'BLENDER_EEVEE'
|
150 |
+
|
151 |
+
##world = bpy.context.scene.world
|
152 |
+
##bg_node = world.node_tree.nodes['Background']
|
153 |
+
##bg_node.image = img
|
154 |
+
|
155 |
+
##env_data = bpy.data.worlds['World'].node_tree.nodes['Background'].input
|
156 |
+
##env_data.default_value = img
|
157 |
+
|
158 |
+
##tex_environment = bpy.data.worlds['World'].node_tree.nodes.new('ShaderNodeTexEnvironment')
|
159 |
+
##tex_environment.image = img
|
160 |
+
##world = bpy.context.scene.world
|
161 |
+
##bg_node = world.node_tree.nodes['Background']
|
162 |
+
##world.node_tree.links.new(tex_environment.outputs[0], bg_node.inputs[0])
|
163 |
+
|
164 |
+
##img = bpy.data.images.load(image_path)
|
165 |
+
world = bpy.context.scene.world
|
166 |
+
if not world.use_nodes:
|
167 |
+
world.use_nodes = True
|
168 |
+
tree = world.node_tree
|
169 |
+
bg_node = tree.nodes.new(type='ShaderNodeTexEnvironment')
|
170 |
+
bg_node.image = img
|
171 |
+
tree.links.new(bg_node.outputs[0], tree.nodes['Background'].inputs[0])
|
172 |
+
|
173 |
+
##world.light_settings.use_ambient_occlusion = True
|
174 |
+
##world.light_settings.ao_factor = 0.5
|
175 |
+
##world.light_settings.ao_factor = 0.5
|
176 |
+
##world.light_settings.use_environment_light = True
|
177 |
+
##world.light_settings.environment_energy = 0.5
|
178 |
+
|
179 |
+
bpy.data.objects['Cube'].select_set(True)
|
180 |
+
bpy.ops.object.delete()
|
181 |
+
bpy.data.objects['Camera'].select_set(True)
|
182 |
+
bpy.ops.object.delete()
|
183 |
+
|
184 |
+
light_data = bpy.data.lights.new(name="NewLight", type='SUN')
|
185 |
+
light_data.energy = 30
|
186 |
+
light_object = bpy.data.objects.new(name="NewLight", object_data=light_data)
|
187 |
+
scene.collection.objects.link(light_object)
|
188 |
+
light_object.location = (3.0, 5.0, 11.0)
|
189 |
+
|
190 |
+
camera_data = bpy.data.cameras.new(name='Camera')
|
191 |
+
camera = bpy.data.objects.new('Camera', camera_data)
|
192 |
+
bpy.context.collection.objects.link(camera)
|
193 |
+
bpy.context.scene.camera = camera
|
194 |
+
camera.location = (0, 0, 10)
|
195 |
+
camera.rotation_euler = (0, 0, 0)
|
196 |
+
##planet1 = add_planet("earth", 2.5, 1, 0)
|
197 |
+
##planet2 = add_planet("mars", 1.75, 0.5, 1.5)
|
198 |
+
add_planet("earth", 2.5, 1, 0)
|
199 |
+
add_planet("mars", 1.75, 0.5, 1.5)
|
200 |
+
##bpy.context.active_object=None
|
201 |
+
|
202 |
+
|
203 |
+
|
204 |
+
add_animated_space_rocks()
|
205 |
+
create_meteor_with_particle_system()
|
206 |
+
create_particle_effects_animation()
|
207 |
+
##create_planet_flyby_animation(planet1, 4, 2)
|
208 |
+
create_scene()
|
209 |
+
|
210 |
+
def export_blend():
|
211 |
+
##bpy.ops.wm.save_mainfile(filepath='./path_to_exp.blend')
|
212 |
+
bpy.ops.wm.save_as_mainfile(filepath='./exp_scene.blend')
|
213 |
+
##bpy.ops.export_scene.obj(filepath='./exp_scene.obj', export_format='OBJ', export_materials='EXPORT')
|
214 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB', check_existing=False, export_image_format='AUTO', export_materials='EXPORT', export_cameras=True, export_lights=True)
|
215 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.gltf', export_selected=False)
|
216 |
+
##cntxt = bpy.context
|
217 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB')
|
218 |
+
##bpy.ops.export_scene.gltf(cntxt, RenderSettings)
|
219 |
+
last_created_time = 0
|
220 |
+
last_created_file = None
|
221 |
+
apol=[]
|
222 |
+
|
223 |
+
for root, dirs, files in os.walk('.'):
|
224 |
+
for file in files:
|
225 |
+
file_path = os.path.join(root, file)
|
226 |
+
created_time = os.path.getctime(file_path)
|
227 |
+
if created_time > last_created_time:
|
228 |
+
last_created_time = created_time
|
229 |
+
last_created_file = file_path
|
230 |
+
|
231 |
+
##imoge = load_image(last_created_file).convert('RGB').resize((512, 512))
|
232 |
+
apol.append(last_created_file)
|
233 |
+
##return last_created_file
|
234 |
+
##return fin_rend
|
235 |
+
##return apol
|
236 |
+
return last_created_file
|
237 |
+
|
238 |
+
def render_scene(blk,sny):
|
239 |
+
bpy.context.scene.render.filepath = './rendered_scene.png'
|
240 |
+
bpy.ops.render.render(animation=False, write_still=True)
|
241 |
+
##bpy.ops.render.opengl(animation=False, render_keyed_only=False, sequencer=False, write_still=True, view_context=False)
|
242 |
+
##imoge = load_image(fin_rend)
|
243 |
+
##imoge.save('./rendered_scene.png', 'PNG')
|
244 |
+
##imoge = PIL.Image(fin_rend)
|
245 |
+
##imoge = load_image().convert('RGB').resize((512, 512))
|
246 |
+
last_created_time = 0
|
247 |
+
last_created_file = None
|
248 |
+
apol=[]
|
249 |
+
|
250 |
+
for root, dirs, files in os.walk('.'):
|
251 |
+
for file in files:
|
252 |
+
file_path = os.path.join(root, file)
|
253 |
+
created_time = os.path.getctime(file_path)
|
254 |
+
if created_time > last_created_time:
|
255 |
+
last_created_time = created_time
|
256 |
+
last_created_file = file_path
|
257 |
+
|
258 |
+
imoge = load_image(last_created_file).convert('RGB').resize((512, 512))
|
259 |
+
apol.append(imoge)
|
260 |
+
##blk=gr.HTML(value="""<html><head><title>Three.js Blender Scene Viewer</title><style>body { margin: 0; } canvas { display: block; } </style></head><body><script src='https://threejs.org/build/three.js'></script><script src='https://threejs.org/examples/jsm/loaders/GLTFLoader.js'></script><script> var scene, camera, renderer; function init() { scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); camera.position.z = 5; renderer = new THREE.WebGLRenderer({antialias: true}); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); var loader = new THREE.GLTFLoader(); loader.load('"""+sny+"""', function(gltf) { scene.add(gltf.scene); }, undefined, function(error) { console.error(error); }); }; function animate(){ requestAnimationFrame(animate); renderer.render(scene, camera); }; init(); animate();</script></body></html>""")
|
261 |
+
pckg = f"/file={sny}"
|
262 |
+
moog = gr.Model3D(value=sny)
|
263 |
+
return apol, f"""<iframe src="file=frame.html" width="100%" height="200px" data-glb="exp_scene.glb"></iframe>""", sny, moog
|
264 |
+
|
265 |
+
##blk=gr.HTML(value=html)
|
266 |
+
##return last_created_file
|
267 |
+
##return fin_rend
|
268 |
+
##return apol,blk,sny
|
269 |
+
|
270 |
+
def export_obj():
|
271 |
+
##bpy.ops.wm.save_mainfile(filepath='./path_to_exp.blend')
|
272 |
+
##bpy.ops.wm.save_as_mainfile(filepath='./exp_scene.blend')
|
273 |
+
##bpy.ops.export_scene.obj(filepath='./exp_scene.obj', export_format='OBJ', export_materials='EXPORT')
|
274 |
+
bpy.ops.export_scene.gltf(filepath="./exp_scene.obj", export_format='OBJ', export_selected=False, export_apply=False, export_texcoords='TANGENT', export_normals='FACE', export_materials='EXPORT', export_colors='EXPORT', export_cameras='EXPORT', export_lights='EXPORT', export_displacement='NONE', export_animations=True, export_frame_range=True, export_frame_step=1, export_force_sampling=False, export_current_frame=False, export_extras=True)
|
275 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB', check_existing=False, export_image_format='AUTO', export_materials='EXPORT', export_cameras=True, export_lights=True)
|
276 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.gltf', export_selected=False)
|
277 |
+
##cntxt = bpy.context
|
278 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB')
|
279 |
+
##bpy.ops.export_scene.gltf(cntxt, RenderSettings)
|
280 |
+
last_created_time = 0
|
281 |
+
last_created_file = None
|
282 |
+
apol=[]
|
283 |
+
|
284 |
+
for root, dirs, files in os.walk('.'):
|
285 |
+
for file in files:
|
286 |
+
file_path = os.path.join(root, file)
|
287 |
+
created_time = os.path.getctime(file_path)
|
288 |
+
if created_time > last_created_time:
|
289 |
+
last_created_time = created_time
|
290 |
+
last_created_file = file_path
|
291 |
+
|
292 |
+
##imoge = load_image(last_created_file).convert('RGB').resize((512, 512))
|
293 |
+
apol.append(last_created_file)
|
294 |
+
##return last_created_file
|
295 |
+
##return fin_rend
|
296 |
+
return apol
|
297 |
+
|
298 |
+
def export_glb():
|
299 |
+
##bpy.ops.wm.save_mainfile(filepath='./path_to_exp.blend')
|
300 |
+
##bpy.ops.wm.save_as_mainfile(filepath='./exp_scene.blend')
|
301 |
+
##bpy.ops.export_scene.obj(filepath='./exp_scene.obj', export_format='OBJ', export_materials='EXPORT')
|
302 |
+
##for ob in bpy.context.scene.objects:
|
303 |
+
## ob.select_set(False)
|
304 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB', export_image_format='NONE', export_materials='NONE', export_cameras=True, export_lights=True)
|
305 |
+
bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB')##, export_image_format='AUTO', export_materials='EXPORT', export_cameras=True, export_lights=True)
|
306 |
+
##export_settings = {
|
307 |
+
##'filepath': './exp_scene.glb',
|
308 |
+
##'export_format': 'GLB',
|
309 |
+
##'gltf_current_frame': 1,
|
310 |
+
##}
|
311 |
+
|
312 |
+
##gltf2_blender_export.save(bpy.context, export_settings)
|
313 |
+
##bpy.ops.export_scene.gltf(filepath="./exp_scene.glb", export_format='GLB', export_selected=False, export_apply=False, export_texcoords=True, export_normals=True, export_materials=True, export_colors=True, export_cameras=True, export_lights=True, export_displacement=False, export_animations=True, export_frame_range=True, export_frame_step=1, export_force_sampling=False, export_current_frame=False, export_extras=True)
|
314 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.gltf', export_selected=False)
|
315 |
+
##cntxt = bpy.context
|
316 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB')
|
317 |
+
##bpy.ops.export_scene.gltf(cntxt, RenderSettings)
|
318 |
+
last_created_time = 0
|
319 |
+
last_created_file = None
|
320 |
+
apol=[]
|
321 |
+
|
322 |
+
for root, dirs, files in os.walk('.'):
|
323 |
+
for file in files:
|
324 |
+
file_path = os.path.join(root, file)
|
325 |
+
created_time = os.path.getctime(file_path)
|
326 |
+
if created_time > last_created_time:
|
327 |
+
last_created_time = created_time
|
328 |
+
last_created_file = file_path
|
329 |
+
|
330 |
+
##imoge = load_image(last_created_file).convert('RGB').resize((512, 512))
|
331 |
+
apol.append(last_created_file)
|
332 |
+
##return last_created_file
|
333 |
+
##return fin_rend
|
334 |
+
##return apol
|
335 |
+
return last_created_file
|
336 |
+
|
337 |
+
def export_gltf():
|
338 |
+
##bpy.ops.wm.save_mainfile(filepath='./path_to_exp.blend')
|
339 |
+
##bpy.ops.wm.save_as_mainfile(filepath='./exp_scene.blend')
|
340 |
+
##bpy.ops.export_scene.obj(filepath='./exp_scene.obj', export_format='OBJ', export_materials='EXPORT')
|
341 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB', check_existing=False, export_image_format='AUTO', export_materials='EXPORT', export_cameras=True, export_lights=True)
|
342 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.gltf',export_format='GLTF_SEPARATE')
|
343 |
+
bpy.ops.export_scene.gltf(filepath='./exp_scene.gltf',export_format='GLB')
|
344 |
+
##cntxt = bpy.context
|
345 |
+
##bpy.ops.export_scene.gltf(filepath='./exp_scene.glb', export_format='GLB')
|
346 |
+
##bpy.ops.export_scene.gltf(cntxt, RenderSettings)
|
347 |
+
last_created_time = 0
|
348 |
+
last_created_file = None
|
349 |
+
apol=[]
|
350 |
+
|
351 |
+
for root, dirs, files in os.walk('.'):
|
352 |
+
for file in files:
|
353 |
+
file_path = os.path.join(root, file)
|
354 |
+
created_time = os.path.getctime(file_path)
|
355 |
+
if created_time > last_created_time:
|
356 |
+
last_created_time = created_time
|
357 |
+
last_created_file = file_path
|
358 |
+
|
359 |
+
##imoge = load_image(last_created_file).convert('RGB').resize((512, 512))
|
360 |
+
apol.append(last_created_file)
|
361 |
+
##return last_created_file
|
362 |
+
##return fin_rend
|
363 |
+
##return apol
|
364 |
+
return last_created_file
|
365 |
+
|
366 |
+
def render_anim():
|
367 |
+
bpy.context.scene.render.image_settings.file_format = 'FFMPEG'
|
368 |
+
bpy.context.scene.render.ffmpeg.format = 'MPEG4'
|
369 |
+
bpy.context.scene.render.ffmpeg.codec = 'H264'
|
370 |
+
bpy.context.scene.render.ffmpeg.constant_rate_factor = 'HIGH'
|
371 |
+
bpy.context.scene.frame_start = 1
|
372 |
+
bpy.context.scene.frame_end = 20
|
373 |
+
bpy.context.scene.render.filepath = './animation.mp4'
|
374 |
+
bpy.ops.render.render(animation=True)
|
375 |
+
|
376 |
+
last_created_time = 0
|
377 |
+
last_created_file = None
|
378 |
+
apol=[]
|
379 |
+
|
380 |
+
for root, dirs, files in os.walk('.'):
|
381 |
+
for file in files:
|
382 |
+
file_path = os.path.join(root, file)
|
383 |
+
created_time = os.path.getctime(file_path)
|
384 |
+
if created_time > last_created_time:
|
385 |
+
last_created_time = created_time
|
386 |
+
last_created_file = file_path
|
387 |
+
|
388 |
+
##imoge = load_image(last_created_file).convert('RGB').resize((512, 512))
|
389 |
+
apol.append(last_created_file)
|
390 |
+
##return last_created_file
|
391 |
+
##return fin_rend
|
392 |
+
return apol[0]
|
393 |
+
|
394 |
+
##return fin_anim
|
395 |
+
|
396 |
+
##export_glb()
|
397 |
+
##export_gltf()
|
398 |
+
##export_blend()
|
399 |
+
|
400 |
+
with gr.Blocks() as iface:
|
401 |
+
with gr.Column():
|
402 |
+
# HTML block to view the exported scene using Three.js
|
403 |
+
|
404 |
+
moog = gr.Model3D()
|
405 |
+
##zery = gr.Button("create Scene")
|
406 |
+
ony = gr.Button("render Image")
|
407 |
+
twy = gr.Button("render Animation")
|
408 |
+
rani = gr.Video()
|
409 |
+
rdr = gr.Gallery(columns=1)
|
410 |
+
sny = gr.File(value=export_glb(),interactive=False)
|
411 |
+
##sey = gr.File(value=export_gltf(),interactive=False)
|
412 |
+
siy = gr.File(value=export_blend(),interactive=False)
|
413 |
+
blk=gr.HTML(value="")
|
414 |
+
|
415 |
+
ony.click(render_scene, [blk,sny], [rdr,blk,sny,moog])
|
416 |
+
twy.click(render_anim, None, rani)
|
417 |
+
|
418 |
+
iface.launch()
|
ear0xuu2.jpg
ADDED
![]() |
Git LFS Details
|
mar0kuu2 (1).jpg
ADDED
![]() |
packages (1).txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
libegl1-mesa-dev
|
2 |
+
libgl1-mesa-dev
|
requirements (20).txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
bpy
|
3 |
+
diffusers
|