-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsd_generator.py
More file actions
executable file
·47 lines (33 loc) · 1.27 KB
/
Copy pathsd_generator.py
File metadata and controls
executable file
·47 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import time
import fal_client # Import the FLUX client
from pathlib import Path
import logging
logger = logging.getLogger(__name__)
start_time = time.time()
temp_image_path = "./image_temp/"
def preview_and_generate_image(character_name, sd_prompt, token):
try:
logger.info(f"Generating image for character: {character_name} with prompt: {sd_prompt}")
request_handle = fal_client.submit(
"fal-ai/flux/dev",
arguments={
"num_inference_steps": 35,
"prompt": sd_prompt,
"num_images": 4,
"strength": 0.85,
"width": 1024,
"height": 1024
}
)
result = request_handle.get()
logger.info(f"API result: {result}")
image_urls = [img['url'] for img in result.get('images', [])]
if not image_urls:
logger.warning("No images were generated.")
return []
logger.info(f"Generated image URLs: {image_urls}")
return image_urls
except Exception as e:
logger.error(f"Error during API call or processing: {str(e)}")
logger.exception("Full traceback:")
return []