Update app.py
Browse files
app.py
CHANGED
|
@@ -40,9 +40,6 @@ def query_with_auto_routing(prompt, model, custom_lora, is_negative=False, steps
|
|
| 40 |
if not api_key:
|
| 41 |
raise gr.Error("HF_READ_TOKEN not found. Please set your Hugging Face API token.")
|
| 42 |
|
| 43 |
-
# Initialize client with automatic provider selection (default is "auto")
|
| 44 |
-
client = InferenceClient(api_key=api_key)
|
| 45 |
-
|
| 46 |
# Determine the model to use
|
| 47 |
if custom_lora.strip() != "":
|
| 48 |
model_id = custom_lora.strip()
|
|
@@ -54,10 +51,12 @@ def query_with_auto_routing(prompt, model, custom_lora, is_negative=False, steps
|
|
| 54 |
# Apply model-specific prompt enhancements
|
| 55 |
enhanced_prompt = apply_model_prompt_enhancements(model, enhanced_prompt)
|
| 56 |
|
| 57 |
-
# Generate image using
|
| 58 |
if input_image is not None:
|
| 59 |
-
# Image-to-image generation
|
| 60 |
print(f"Performing image-to-image generation with model: {model_id}")
|
|
|
|
|
|
|
| 61 |
image = client.image_to_image(
|
| 62 |
image=input_image,
|
| 63 |
prompt=enhanced_prompt,
|
|
@@ -69,7 +68,8 @@ def query_with_auto_routing(prompt, model, custom_lora, is_negative=False, steps
|
|
| 69 |
# Note: strength parameter is handled differently in image_to_image
|
| 70 |
)
|
| 71 |
else:
|
| 72 |
-
# Text-to-image generation
|
|
|
|
| 73 |
image = client.text_to_image(
|
| 74 |
prompt=enhanced_prompt,
|
| 75 |
model=model_id,
|
|
@@ -618,6 +618,9 @@ with gr.Blocks(theme='Nymbo/Alyx_Theme') as dalle:
|
|
| 618 |
with gr.Accordion("Advanced Settings Overview", open=False):
|
| 619 |
gr.Markdown(
|
| 620 |
"""
|
|
|
|
|
|
|
|
|
|
| 621 |
## Negative Prompt
|
| 622 |
###### This box is for telling the AI what you don't want in your images. Think of it as a way to avoid certain elements. For instance, if you don't want blurry images or extra limbs showing up, this is where you'd mention it.
|
| 623 |
|
|
|
|
| 40 |
if not api_key:
|
| 41 |
raise gr.Error("HF_READ_TOKEN not found. Please set your Hugging Face API token.")
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
# Determine the model to use
|
| 44 |
if custom_lora.strip() != "":
|
| 45 |
model_id = custom_lora.strip()
|
|
|
|
| 51 |
# Apply model-specific prompt enhancements
|
| 52 |
enhanced_prompt = apply_model_prompt_enhancements(model, enhanced_prompt)
|
| 53 |
|
| 54 |
+
# Generate image using appropriate provider
|
| 55 |
if input_image is not None:
|
| 56 |
+
# Image-to-image generation - use Replicate provider as it supports image-to-image
|
| 57 |
print(f"Performing image-to-image generation with model: {model_id}")
|
| 58 |
+
print("Using Replicate provider for image-to-image generation")
|
| 59 |
+
client = InferenceClient(provider="replicate", api_key=api_key)
|
| 60 |
image = client.image_to_image(
|
| 61 |
image=input_image,
|
| 62 |
prompt=enhanced_prompt,
|
|
|
|
| 68 |
# Note: strength parameter is handled differently in image_to_image
|
| 69 |
)
|
| 70 |
else:
|
| 71 |
+
# Text-to-image generation - use automatic provider selection
|
| 72 |
+
client = InferenceClient(api_key=api_key)
|
| 73 |
image = client.text_to_image(
|
| 74 |
prompt=enhanced_prompt,
|
| 75 |
model=model_id,
|
|
|
|
| 618 |
with gr.Accordion("Advanced Settings Overview", open=False):
|
| 619 |
gr.Markdown(
|
| 620 |
"""
|
| 621 |
+
## Enable Image Editing
|
| 622 |
+
###### When enabled, this feature allows you to upload an image and use the FLUX.1-Kontext-dev model to edit it. This model specializes in image-to-image transformations, allowing you to modify existing images based on your text prompts. The system automatically uses the Replicate provider for image-to-image generation as it supports this functionality.
|
| 623 |
+
|
| 624 |
## Negative Prompt
|
| 625 |
###### This box is for telling the AI what you don't want in your images. Think of it as a way to avoid certain elements. For instance, if you don't want blurry images or extra limbs showing up, this is where you'd mention it.
|
| 626 |
|