File size: 949 Bytes
e8a594e
459637f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from diffusers import StableDiffusionPipeline
import matplotlib.pyplot as plt
import torch

model_id1 = "dreamlike-art/dreamlike-diffusion-1.0"

pipe = StableDiffusionPipeline.from_pretrained(model_id1, use_safetensors=True)
pipe = pipe.to("cpu")

def generate_image_interface(prompt):
    # Assuming `pipe` is correctly defined elsewhere for image generation
    params = {
        'prompt': prompt,
        'num_inference_steps': 100,
        'num_images_per_prompt': 2,  # Assuming this is a valid parameter
        'height': int(1.2 * 640)  # Assuming height is calculated based on weight
    }

    # Assuming `pipe` is correctly defined elsewhere
    img = pipe(**params).images
    return img[0], img[1]

import gradio as gr

demo = gr.Interface(
    fn=generate_image_interface,
    inputs=["text"],
    outputs=["image", "image"],
    title="Image Generation Interface",
    description="Generate images based on prompts."
)

demo.launch()