start pipeline script dynamically calculates absolute paths
This commit is contained in:
		
							parent
							
								
									e4f9423ca6
								
							
						
					
					
						commit
						6413d5a3d6
					
				
							
								
								
									
										
											BIN
										
									
								
								3d-generation-pipeline/images/2025-10-20-16-24-45.jpg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								3d-generation-pipeline/images/2025-10-20-16-24-45.jpg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								3d-generation-pipeline/images/2025-10-20-16-32-50.jpg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								3d-generation-pipeline/images/2025-10-20-16-32-50.jpg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								3d-generation-pipeline/models/2025-10-20-16-32-50/0/input.png
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								3d-generation-pipeline/models/2025-10-20-16-32-50/0/input.png
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								3d-generation-pipeline/models/2025-10-20-16-32-50/0/mesh.glb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								3d-generation-pipeline/models/2025-10-20-16-32-50/0/mesh.glb
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -2,6 +2,7 @@ import os
 | 
				
			|||||||
import base64
 | 
					import base64
 | 
				
			||||||
import requests
 | 
					import requests
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
 | 
					from pathlib import Path
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime
 | 
				
			||||||
from dotenv import load_dotenv
 | 
					from dotenv import load_dotenv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -15,7 +16,7 @@ def get_timestamp():
 | 
				
			|||||||
    return datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
 | 
					    return datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def text_to_image(prompt, output_name):
 | 
					def text_to_image(prompt, output_path):
 | 
				
			||||||
    MODEL = "@cf/black-forest-labs/flux-1-schnell"
 | 
					    MODEL = "@cf/black-forest-labs/flux-1-schnell"
 | 
				
			||||||
    URL = f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/{MODEL}"
 | 
					    URL = f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/{MODEL}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -38,11 +39,9 @@ def text_to_image(prompt, output_name):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    img_bytes = base64.b64decode(b64)
 | 
					    img_bytes = base64.b64decode(b64)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    out_path = f"images/{output_name}.jpg"
 | 
					    with open(output_path, "wb") as f:
 | 
				
			||||||
    with open(out_path, "wb") as f:
 | 
					 | 
				
			||||||
        f.write(img_bytes)
 | 
					        f.write(img_bytes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return out_path
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def refine_text_prompt(prompt):
 | 
					def refine_text_prompt(prompt):
 | 
				
			||||||
    MODEL = "@cf/meta/llama-3.2-3b-instruct"
 | 
					    MODEL = "@cf/meta/llama-3.2-3b-instruct"
 | 
				
			||||||
@ -70,7 +69,8 @@ def refine_text_prompt(prompt):
 | 
				
			|||||||
def image_to_3d(image_path, output_path):
 | 
					def image_to_3d(image_path, output_path):
 | 
				
			||||||
    import subprocess
 | 
					    import subprocess
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MODEL_FOLDER = r"D:\users\henrisel\stable-fast-3d"
 | 
					    # TODO: make this configurable
 | 
				
			||||||
 | 
					    MODEL_FOLDER = r"D:\henrisel\AI-models\stable-fast-3d"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    venv_python = MODEL_FOLDER + r"\.venv\Scripts\python.exe"
 | 
					    venv_python = MODEL_FOLDER + r"\.venv\Scripts\python.exe"
 | 
				
			||||||
    script_path = MODEL_FOLDER + r"\run.py"
 | 
					    script_path = MODEL_FOLDER + r"\run.py"
 | 
				
			||||||
@ -99,11 +99,13 @@ def main():
 | 
				
			|||||||
    print(f"User prompt: {user_prompt}")
 | 
					    print(f"User prompt: {user_prompt}")
 | 
				
			||||||
    refined_prompt = refine_text_prompt(user_prompt)
 | 
					    refined_prompt = refine_text_prompt(user_prompt)
 | 
				
			||||||
    print(f"Refined prompt: {refined_prompt}")
 | 
					    print(f"Refined prompt: {refined_prompt}")
 | 
				
			||||||
    image_path = text_to_image(refined_prompt, get_timestamp())
 | 
					    timestamp = get_timestamp()
 | 
				
			||||||
 | 
					    image_path = Path.cwd() / "images" / f"{timestamp}.jpg"
 | 
				
			||||||
 | 
					    text_to_image(refined_prompt, image_path)
 | 
				
			||||||
    print(f"Generated image file: {image_path}")
 | 
					    print(f"Generated image file: {image_path}")
 | 
				
			||||||
    output_path = r"\models"
 | 
					    model_path = Path.cwd() / "models" / timestamp
 | 
				
			||||||
    image_to_3d(image_path, output_path)
 | 
					    image_to_3d(image_path, model_path)
 | 
				
			||||||
    print(f"Generated 3D model file: {output_path}")
 | 
					    print(f"Generated 3D model file: {model_path}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user