dassum commited on
Commit
3e253b4
β€’
1 Parent(s): 83f7ff7

Updated from colab

Browse files
Files changed (2) hide show
  1. app.py +38 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from diffusers import StableDiffusionPipeline
4
+
5
+ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
6
+ pipe = pipe.to("cuda")
7
+ client = Client('abidlabs/GFPGAN')
8
+
9
+ # setting=Tom Hanks nightwing in real life camera, high-def, high-res, 4k, dark night, raining, thunder
10
+ def predict(celebrity, movie,setting):
11
+ 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}"
12
+ image = pipe(prompt).images[0]
13
+ tmpFileName = 'tmp_image.png'
14
+ image.save(tmpFileName, 'PNG')
15
+ gfpGanFileName = client.predict(tmpFileName, 2)
16
+
17
+ return Image.open(gfpGanFileName)
18
+
19
+ import gradio as gr
20
+ import os
21
+
22
+ HF_TOKEN = os.getenv('HF_TOKEN')
23
+ hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "movie-poster")
24
+
25
+ gr.Interface(
26
+ fn = predict,
27
+ inputs=[
28
+ gr.inputs.Textbox(label="celebrity"),
29
+ gr.inputs.Dropdown(label="Movies", choices=["Batman", "Gladiator", "Mission Impossible"]),
30
+ gr.inputs.Textbox(label="Setting")
31
+ ],
32
+ outputs= gr.outputs.Image(label="Generated movie poster",type='pil'),
33
+ description="Generate a movie poster with the given information",
34
+ title = "Movie Poster Generator",
35
+ allow_flagging="manual",
36
+ flagging_options=["Good", "Better", "Worst"],
37
+ flagging_callback=hf_writer
38
+ ).launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ transformers
2
+ huggingface_hub
3
+ diffusers
4
+ gradio
5
+ Pillow