Spaces:
Runtime error
Runtime error
| import re | |
| import os | |
| import requests | |
| import gradio as gr | |
| from datasets import load_dataset | |
| from PIL import Image | |
| import torch | |
| from torch import autocast | |
| from transformers import pipeline, set_seed | |
| from diffusers import DiffusionPipeline, StableDiffusionPipeline | |
| # Config | |
| DEVICE = "cuda" | |
| # GPT2 | |
| generator = pipeline('text-generation', model='gpt2') | |
| set_seed(42) | |
| generator("Hello world, I'm vizard,", max_length=50, num_return_sequences=3) | |
| # SD v1.4 | |
| def get_stable_diffusion_v14_pipeline(): | |
| model_id = "CompVis/stable-diffusion-v1-4" | |
| pipeline = StableDiffusionPipeline.from_pretrained(mode_id) | |
| # pipeline = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True, revision="fp16", torch_dtype=torch.float16) | |
| pipeline = pipeline.to(DEVICE) | |
| torch.backends.cudnn.benchmark = True | |
| return pipeline | |
| # SD v1.5 | |
| def get_stable_diffusion_v15_pipeline(): | |
| model_id = "runwayml/stable-diffusion-v1-5" | |
| pipeline = DiffusionPipeline.from_pretrained(mode_id) | |
| pipeline = pipeline.to(DEVICE) | |
| return pipeline | |
| # main | |
| def main(): | |
| prompt = "Hello world, I'm vizard," | |
| pipeline = get_stable_diffusion_v15_pipeline() | |
| images = pipeline(prompt).images | |
| main |