andresgtn commited on
Commit
3cb2568
1 Parent(s): d261ad3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -9,6 +9,7 @@ import os
9
 
10
  # required for stable difussion
11
  auth_token = os.environ.get("auth_token") #in secret space
 
12
 
13
  pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=auth_token)
14
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
@@ -63,11 +64,15 @@ def generate(celebrity, movie, guidance, improve_flag, scale): # add scale as va
63
  image = improve_image(image, scale=scale)
64
  return image
65
 
66
- movie_options = ["James Bond", "Snatch", "Saving Private Ryan", "Miss Congeniality", "Scarface", "Avatar", "Top Gun"]
67
- title = "Movie Poster Celebrity Swap"
68
- description = "Write the name of a celebrity, and pick a movie from the dropdown menu.\
69
- It will generate a new movie poster (inspired by your chosen movie)\
70
- with the chosen celebrity in it. See below for explanation of the\
 
 
 
 
71
  input variables."
72
  article= "Inputs explained: \n Guidance: the lower, the more random the output\
73
  image. Improve and scale: if selected, the image will be refined\
@@ -75,8 +80,8 @@ article= "Inputs explained: \n Guidance: the lower, the more random the output\
75
 
76
  demo = gr.Interface(
77
  fn=generate,
78
- inputs=[gr.Textbox(value="Daniel Craig"),
79
- gr.Dropdown(movie_options, value="Saving Private Ryan"),
80
  gr.Slider(1, 20, value=7.5, step=0.5),
81
  gr.Checkbox(label="Improve and scale? (extra time)"),
82
  gr.Slider(1, 3, value=1, step=0.5)
@@ -84,7 +89,10 @@ demo = gr.Interface(
84
  outputs='image',
85
  title=title,
86
  description=description,
87
- article=article
 
 
 
88
  )
89
 
90
  demo.launch()
 
9
 
10
  # required for stable difussion
11
  auth_token = os.environ.get("auth_token") #in secret space
12
+ hf_writer = gr.HuggingFaceDatasetSaver(auth_token, "flagged-movie-poster-celebrity-swap")
13
 
14
  pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=auth_token)
15
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
 
64
  image = improve_image(image, scale=scale)
65
  return image
66
 
67
+ movie_options = movie_options = ["Casino Royale (2006)",
68
+ "Quantum of Solace (2008)",
69
+ "Skyfall (2012)",
70
+ "Spectre (2015)",
71
+ "No Time To Die (2021)"]
72
+ title = "Find the new James Bond"
73
+ description = "Write the name of a celebrity, and pick a Bond movie from the dropdown menu.\
74
+ This will generate a new movie poster (inspired by the chosen movie)\
75
+ with the new celebrity in it. See below for explanation of the\
76
  input variables."
77
  article= "Inputs explained: \n Guidance: the lower, the more random the output\
78
  image. Improve and scale: if selected, the image will be refined\
 
80
 
81
  demo = gr.Interface(
82
  fn=generate,
83
+ inputs=[gr.Textbox(value="Emma Watson"),
84
+ gr.Dropdown(movie_options, value="Skyfall (2012)"),
85
  gr.Slider(1, 20, value=7.5, step=0.5),
86
  gr.Checkbox(label="Improve and scale? (extra time)"),
87
  gr.Slider(1, 3, value=1, step=0.5)
 
89
  outputs='image',
90
  title=title,
91
  description=description,
92
+ article=article,
93
+ allow_flagging="manual",
94
+ flagging_options=["wrong celebrity", "wrong movie", "face not shown", "nonsensical output"],
95
+ flagging_callback=hf_writer
96
  )
97
 
98
  demo.launch()