File size: 514 Bytes
012145c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
import numpy as np

model_id = "Joeythemonster/anything-midjourney-v-4-1"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
pipe = pipe.to("cpu")


def generate_image(prompt):
    image = pipe(prompt).images[0]
    image = np.asarray(image)
    return image

iface = gr.Interface(generate_image, gr.inputs.Textbox(label="Enter a prompt"), gr.outputs.Image(type='numpy'), batch_size=1)

iface.launch()