You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the example below, I'd like to instantiate the model once and generate multiple images. In some cases, the image may require a LoRA or Multiple LoRAs.
# Load the model
flux = Flux1.from_name(
model_name="schnell", # "schnell" or "dev"
quantize=8, # 4 or 8
)
# Generate an image
image = flux.generate_image(
seed=2,
prompt="Luxury food photograph",
config=Config(
num_inference_steps=2, # "schnell" works well with 2-4 steps, "dev" works well with 20-25 steps
height=1024,
width=1024,
)
)
image.save(path="image.png")
Is there a way to do something like this to set and reset LoRAs per image being created rather than having to initialize the model again?
from mflux import Flux1, Config
# Load the model
flux = Flux1.from_name(
model_name="schnell", # "schnell" or "dev"
quantize=8, # 4 or 8
)
foo = {
'a': {'prompt': 'foo',
'lora': '/usr/local/fbar'},
'b': {'prompt': 'bar'},
'c': {'prompt': 'fubar',
'lora': ['/usr/local/fbar', '/usr/lcoal/bbar'],
'scales': '0.5 0.9'
}
}
for key, value in foo.items():
if 'lora' in value and value['lora']:
flux.lora_paths = value['lora']
else:
# reset the lora to nothing in case this image doesn't have one
flux.lora_paths = None
if 'scales' in value and value['scales']:
flux.lora_scales = value['scales']
else:
# reset the lora to nothing in case this image doesn't have one
flux.lora_scales = Nonex
# Generate an image
image = flux.generate_image(
seed=2,
prompt=p,
config=Config(
num_inference_steps=2, # "schnell" works well with 2-4 steps, "dev" works well with 20-25 steps
height=1024,
width=1024,
)
)
image.save(path="image.png")
The text was updated successfully, but these errors were encountered:
Using the example below, I'd like to instantiate the model once and generate multiple images. In some cases, the image may require a LoRA or Multiple LoRAs.
Is there a way to do something like this to set and reset LoRAs per image being created rather than having to initialize the model again?
The text was updated successfully, but these errors were encountered: