Spaces:
Runtime error
Runtime error
modified: app.py
Browse files
app.py
CHANGED
@@ -52,7 +52,7 @@ pipe_edit.to("cuda")
|
|
52 |
|
53 |
def promptifier(prompt):
|
54 |
client1 = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
55 |
-
system_instructions1 = "<s>[SYSTEM] Act as Image Prompt Generation expert, Your task is to modify prompt by USER to more better prompt for Image Generation in Stable Diffusion XL. \n Modify the user's prompt to generate a high-quality image by incorporating essential keywords and styles according to prompt if none style is mentioned than assume realistic. The optimized prompt may include keywords according to prompt for resolution (4K, HD, 16:9 aspect ratio, , etc.), image quality (cute, masterpiece, high-quality, vivid colors, intricate details, etc.), and desired art styles (realistic, anime, 3D, logo, futuristic, fantasy, etc.). Ensure the prompt is concise, yet comprehensive and choose keywords wisely, to generate an exceptional image that meets the user's expectations. \n Your task is to reply with final optimized prompt only. If you get big prompt make it concise.[USER]"
|
56 |
formatted_prompt = f"{system_instructions1} {prompt} [OPTIMIZED_PROMPT]"
|
57 |
stream = client1.text_generation(formatted_prompt, max_new_tokens=80, stream=True, details=True, return_full_text=False)
|
58 |
return "".join([response.token.text for response in stream if response.token.text != "</s>"])
|
@@ -80,6 +80,7 @@ def king(type ,
|
|
80 |
output_image = pipe_edit(
|
81 |
instruction, negative_prompt=negative_prompt, image=input_image,
|
82 |
guidance_scale=guidance_scale, image_guidance_scale=1.5,
|
|
|
83 |
num_inference_steps=steps, generator=generator, output_type="latent",
|
84 |
).images
|
85 |
refine = refiner(
|
@@ -89,7 +90,6 @@ def king(type ,
|
|
89 |
num_inference_steps=steps,
|
90 |
image=output_image,
|
91 |
generator=generator,
|
92 |
-
width = input_image.width, height = input_image.height,
|
93 |
).images[0]
|
94 |
return seed, refine
|
95 |
else :
|
|
|
52 |
|
53 |
def promptifier(prompt):
|
54 |
client1 = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
55 |
+
system_instructions1 = "<s>[SYSTEM] Act as Image Prompt Generation expert, Your task is to modify prompt by USER to more better prompt for Image Generation in Stable Diffusion XL. \n Modify the user's prompt to generate a high-quality image by incorporating essential keywords and styles according to prompt if none style is mentioned than assume realistic. The optimized prompt may include keywords according to prompt for resolution (4K, HD, 16:9 aspect ratio, , etc.), image quality (cute, masterpiece, high-quality, vivid colors, intricate details, etc.), and desired art styles (realistic, anime, 3D, logo, futuristic, fantasy, etc.). Ensure the prompt is concise, yet comprehensive and choose keywords wisely, to generate an exceptional image that meets the user's expectations. \n Your task is to reply with final optimized prompt only. If you get big prompt make it concise. and Apply all keyword at last of prompt. Reply with optimized prompt only.[USER]"
|
56 |
formatted_prompt = f"{system_instructions1} {prompt} [OPTIMIZED_PROMPT]"
|
57 |
stream = client1.text_generation(formatted_prompt, max_new_tokens=80, stream=True, details=True, return_full_text=False)
|
58 |
return "".join([response.token.text for response in stream if response.token.text != "</s>"])
|
|
|
80 |
output_image = pipe_edit(
|
81 |
instruction, negative_prompt=negative_prompt, image=input_image,
|
82 |
guidance_scale=guidance_scale, image_guidance_scale=1.5,
|
83 |
+
width = input_image.width, height = input_image.height,
|
84 |
num_inference_steps=steps, generator=generator, output_type="latent",
|
85 |
).images
|
86 |
refine = refiner(
|
|
|
90 |
num_inference_steps=steps,
|
91 |
image=output_image,
|
92 |
generator=generator,
|
|
|
93 |
).images[0]
|
94 |
return seed, refine
|
95 |
else :
|