generated from society-ai/simple-image-gen
Update app.py
Some checks failed
society-ai-hub-container-cache Actions Demo / build (push) Has been cancelled
Some checks failed
society-ai-hub-container-cache Actions Demo / build (push) Has been cancelled
This commit is contained in:
parent
4f4e1df28b
commit
bf326688c5
22
app.py
22
app.py
@ -11,9 +11,17 @@ API_URL = 'https://hub.societyai.com/models/flux-1-schnell/infer'
|
|||||||
API_TOKEN = os.environ.get("SAI_API_TOKEN", "")
|
API_TOKEN = os.environ.get("SAI_API_TOKEN", "")
|
||||||
MAX_SEED = np.iinfo(np.int32).max
|
MAX_SEED = np.iinfo(np.int32).max
|
||||||
MAX_IMAGE_SIZE = 2048
|
MAX_IMAGE_SIZE = 2048
|
||||||
|
CYBERPUNK_STYLE = (
|
||||||
|
"Create a highly detailed and visually stunning image in a Cyberpunk theme, "
|
||||||
|
"regardless of the subject or concept described. Use neon lights, futuristic technology, "
|
||||||
|
"gritty urban environments, and cybernetic enhancements as core elements of the design. "
|
||||||
|
"Blend a mix of dystopian aesthetics, vibrant holographic displays, and advanced robotics "
|
||||||
|
"to capture the essence of Cyberpunk, while adapting to the user’s specific prompt or description seamlessly. "
|
||||||
|
"Maintain a bold and immersive atmosphere that conveys a high-tech, neon-lit future."
|
||||||
|
)
|
||||||
|
|
||||||
with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
||||||
gr.Markdown("## FLUX.1-schnell Image Generation")
|
gr.Markdown("## FLUX.1-schnell Cyberpunk Image Generation")
|
||||||
|
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
prompt = gr.Textbox(label="Prompt", lines=2, placeholder="Enter your prompt here")
|
prompt = gr.Textbox(label="Prompt", lines=2, placeholder="Enter your prompt here")
|
||||||
@ -47,19 +55,23 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
|||||||
return None, "Error: Both width and height must be divisible by 8."
|
return None, "Error: Both width and height must be divisible by 8."
|
||||||
if randomize_seed:
|
if randomize_seed:
|
||||||
seed = random.randint(0, MAX_SEED)
|
seed = random.randint(0, MAX_SEED)
|
||||||
|
|
||||||
|
# Combine the Cyberpunk style with the user prompt
|
||||||
|
full_prompt = f"{CYBERPUNK_STYLE} {prompt.strip()}"
|
||||||
|
|
||||||
# Prepare the data payload
|
# Prepare the data payload
|
||||||
inputs = [
|
inputs = [
|
||||||
{
|
{
|
||||||
"name": "PROMPT",
|
"name": "PROMPT",
|
||||||
"shape": [1],
|
"shape": [1],
|
||||||
"datatype": "BYTES",
|
"datatype": "BYTES",
|
||||||
"data": [prompt]
|
"data": [full_prompt]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "INIT_IMAGE",
|
"name": "INIT_IMAGE",
|
||||||
"shape": [1],
|
"shape": [1],
|
||||||
"datatype": "BYTES",
|
"datatype": "BYTES",
|
||||||
"data": [""] # not supported
|
"data": [""] # not supported
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "WIDTH",
|
"name": "WIDTH",
|
||||||
@ -95,7 +107,7 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
|||||||
"name": "IMAGE_STRENGTH",
|
"name": "IMAGE_STRENGTH",
|
||||||
"shape": [1],
|
"shape": [1],
|
||||||
"datatype": "FP32",
|
"datatype": "FP32",
|
||||||
"data": [0.0] # not supported
|
"data": [0.0] # not supported
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -125,7 +137,7 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
|||||||
# Convert to numpy array
|
# Convert to numpy array
|
||||||
image = Image.open(BytesIO(image_data))
|
image = Image.open(BytesIO(image_data))
|
||||||
image_np = np.array(image)
|
image_np = np.array(image)
|
||||||
return image_np, "Image generated successfully.", seed
|
return image_np, "Cyberpunk Image generated successfully.", seed
|
||||||
else:
|
else:
|
||||||
# Handle error
|
# Handle error
|
||||||
return None, f"Error: {response.status_code} - {response.text}", seed
|
return None, f"Error: {response.status_code} - {response.text}", seed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user