hatimanees commited on
Commit
93f033c
·
verified ·
1 Parent(s): 7600a93

Create lehenga_generator.py

Browse files
Files changed (1) hide show
  1. lehenga_generator.py +36 -0
lehenga_generator.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ from diffusers import DiffusionPipeline
4
+
5
+ # Load the model and LoRA weights
6
+ @st.cache_resource
7
+ def load_model():
8
+ pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
9
+ pipe.load_lora_weights("tryonlabs/FLUX.1-dev-LoRA-Lehenga-Generator")
10
+ return pipe
11
+
12
+ pipe = load_model()
13
+
14
+ # App interface
15
+ st.title("Lehenga Dress Image Generator")
16
+ st.write("Enter a description to generate an image of a lehenga dress.")
17
+
18
+ # Input prompt
19
+ prompt = st.text_area("Enter your prompt:",
20
+ "A flat-lay image of a lehenga with a traditional style and a fitted waistline is elegantly crafted from stretchy silk material, ensuring a comfortable and flattering fit. The long hemline adds a touch of grace and sophistication to the ensemble. Adorned in a solid blue color, it features a sleeveless design that complements its sweetheart neckline. The solid pattern and the luxurious silk fabric together create a timeless and chic look that is perfect for special occasions.")
21
+
22
+ # Generate button
23
+ if st.button("Generate Image"):
24
+ if prompt.strip():
25
+ with st.spinner("Generating image..."):
26
+ try:
27
+ # Generate the image
28
+ result = pipe(prompt).images[0]
29
+ # Display the image
30
+ st.image(result, caption="Generated Lehenga Image", use_column_width=True)
31
+ except Exception as e:
32
+ st.error(f"An error occurred: {e}")
33
+ else:
34
+ st.warning("Please enter a valid prompt.")
35
+
36
+ st.write("This app uses AI to generate images of lehenga dresses based on your input description.")