File size: 702 Bytes
742fff7
 
 
de87770
f739757
 
742fff7
 
f739757
742fff7
 
 
 
 
 
 
 
 
 
 
 
 
de87770
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
import numpy as np
import torch
from PIL import Image
from torchvision.utils import save_image
from model import load_model, sample

# Load the pre-trained Stable Diffusion model
model = load_model()

# Function to generate hugging face images
def generate_hugging_face_image():
    z = torch.randn(1, 256, 1, 1).cuda()
    x = sample(model, z, clip_denoised=True)
    save_image(x, 'output.png')
    return 'output.png'

# Streamlit app
st.title('Hugging Face Image Generator')

if st.button('Generate Hugging Face Image'):
    image_path = generate_hugging_face_image()
    image = Image.open(image_path)
    st.image(image, caption='Hugging Face Image', use_column_width=True)