Spaces:
Runtime error
Runtime error
File size: 1,418 Bytes
3e253b4 |
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 35 36 37 38 39 |
import gradio as gr
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
pipe = pipe.to("cuda")
client = Client('abidlabs/GFPGAN')
# setting=Tom Hanks nightwing in real life camera, high-def, high-res, 4k, dark night, raining, thunder
def predict(celebrity, movie,setting):
prompt=f" Create a movie poster featuring {celebrity} along with the movie title. The poster should include the title of the movie as {movie},and in a given settings as {setting}"
image = pipe(prompt).images[0]
tmpFileName = 'tmp_image.png'
image.save(tmpFileName, 'PNG')
gfpGanFileName = client.predict(tmpFileName, 2)
return Image.open(gfpGanFileName)
import gradio as gr
import os
HF_TOKEN = os.getenv('HF_TOKEN')
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "movie-poster")
gr.Interface(
fn = predict,
inputs=[
gr.inputs.Textbox(label="celebrity"),
gr.inputs.Dropdown(label="Movies", choices=["Batman", "Gladiator", "Mission Impossible"]),
gr.inputs.Textbox(label="Setting")
],
outputs= gr.outputs.Image(label="Generated movie poster",type='pil'),
description="Generate a movie poster with the given information",
title = "Movie Poster Generator",
allow_flagging="manual",
flagging_options=["Good", "Better", "Worst"],
flagging_callback=hf_writer
).launch(share=True)
|