hoh2000 commited on
Commit
8281fbe
·
verified ·
1 Parent(s): 3ec475e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -1,18 +1,21 @@
1
- from huggingface_hub import snapshot_download
2
  import gradio as gr
 
3
 
4
- # Download the model to cache or local dir
5
- local_dir = snapshot_download(repo_id="cloudqi/cqi_text_to_image_pt_v0")
6
 
7
- def show_path():
8
- return f"Model downloaded to: {local_dir}"
 
9
 
10
- gr.Interface(fn=show_path, inputs=None, outputs="text").launch()
11
- demo.launch(share=True)
12
-
13
- from diffusers import DiffusionPipeline
 
 
 
 
14
 
15
- pipe = DiffusionPipeline.from_pretrained("cloudqi/cqi_text_to_image_pt_v0")
16
-
17
- prompt = "Gato em alta qualidade na neve\n"
18
- image = pipe(prompt).images[0]
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load the model with remote code
5
+ pipe = pipeline("text-to-image", model="cloudqi/cqi_text_to_image_pt_v0", trust_remote_code=True)
6
 
7
+ def generate_image(prompt):
8
+ result = pipe(prompt)[0] # Get the first generated image
9
+ return result
10
 
11
+ # Create the Gradio interface
12
+ demo = gr.Interface(
13
+ fn=generate_image,
14
+ inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
15
+ outputs="image",
16
+ title="Text-to-Image Generator",
17
+ description="Powered by cloudqi/cqi_text_to_image_pt_v0"
18
+ )
19
 
20
+ # Run with public link enabled
21
+ demo.launch(share=True)