added logging to file
This commit is contained in:
parent
590c62eadd
commit
d7fec73c77
1
3d-generation-pipeline/.gitignore
vendored
1
3d-generation-pipeline/.gitignore
vendored
@ -3,3 +3,4 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
images/
|
images/
|
||||||
models/
|
models/
|
||||||
|
logs/
|
||||||
@ -1,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -18,6 +20,16 @@ PIPELINE_FOLDER = os.environ["PIPELINE_FOLDER"]
|
|||||||
def get_timestamp():
|
def get_timestamp():
|
||||||
return datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
|
return datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
|
||||||
|
|
||||||
|
def setup_logger(base_folder, timestamp):
|
||||||
|
log_dir = base_folder / Path("logs")
|
||||||
|
log_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
logging.basicConfig(
|
||||||
|
filename=log_dir / f"{timestamp}.log",
|
||||||
|
level=logging.INFO,
|
||||||
|
#format='%(asctime)s - %(message)s'
|
||||||
|
force=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
parser = argparse.ArgumentParser(description="Text to 3D model pipeline")
|
parser = argparse.ArgumentParser(description="Text to 3D model pipeline")
|
||||||
@ -34,16 +46,26 @@ async def main():
|
|||||||
else:
|
else:
|
||||||
image_generation_prompt = input_prompt
|
image_generation_prompt = input_prompt
|
||||||
|
|
||||||
timestamp = get_timestamp()
|
|
||||||
pipeline_folder = Path(PIPELINE_FOLDER)
|
pipeline_folder = Path(PIPELINE_FOLDER)
|
||||||
|
timestamp = get_timestamp()
|
||||||
|
setup_logger(pipeline_folder, timestamp)
|
||||||
|
time_checkpoint = time.time()
|
||||||
|
|
||||||
image_path = pipeline_folder / "images" / f"{timestamp}.jpg"
|
image_path = pipeline_folder / "images" / f"{timestamp}.jpg"
|
||||||
# TODO: use Invoke AI or Cloudflare, depending on env var
|
# TODO: use Invoke AI or Cloudflare, depending on env var
|
||||||
#text_to_image_cloudflare(image_generation_prompt, image_path)
|
#text_to_image_cloudflare(image_generation_prompt, image_path)
|
||||||
await text_to_image_invoke_ai(image_generation_prompt, image_path)
|
await text_to_image_invoke_ai(image_generation_prompt, image_path)
|
||||||
|
|
||||||
|
image_generation_time = time.time() - time_checkpoint
|
||||||
|
time_checkpoint = time.time()
|
||||||
|
logging.info(f"Image generation time: {round(image_generation_time, 1)} s")
|
||||||
print(f"Generated image file: {image_path}")
|
print(f"Generated image file: {image_path}")
|
||||||
|
|
||||||
model_path = pipeline_folder / "models" / timestamp
|
model_path = pipeline_folder / "models" / timestamp
|
||||||
model_file = image_to_3d_api(image_path, model_path)
|
model_file = image_to_3d_api(image_path, model_path)
|
||||||
|
|
||||||
|
model_generation_time = time.time() - time_checkpoint
|
||||||
|
logging.info(f"Model generation time: {round(model_generation_time, 1)} s")
|
||||||
print(f"Generated 3D model file: {model_file}")
|
print(f"Generated 3D model file: {model_file}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user