sashavor commited on
Commit
93330ce
·
1 Parent(s): eda017b

resizing images

Browse files
Files changed (1) hide show
  1. app.py +9 -24
app.py CHANGED
@@ -70,18 +70,10 @@ def show_cluster(cl_id, num_clusters):
70
  img_path = "/".join(
71
  [st.replace("/", "") for st in cl_dct["img_path_list"][i].split("//")][3:]
72
  )
73
- images.append(
74
- (
75
- Image.open(os.path.join("identities-images", img_path)),
76
- "_".join([img_path.split("/")[0], img_path.split("/")[-1]])
77
- .replace("Photo_portrait_of_an_", "")
78
- .replace("Photo_portrait_of_a_", "")
79
- .replace("SD_v2_random_seeds_identity_", "(SD v.2) ")
80
- .replace("dataset-identities-dalle2_", "(Dall-E 2) ")
81
- .replace("SD_v1.4_random_seeds_identity_", "(SD v.1.4) ")
82
- .replace("_", " "),
83
- )
84
- )
85
  model_fig = go.Figure()
86
  model_fig.add_trace(
87
  go.Pie(
@@ -128,13 +120,8 @@ def show_cluster(cl_id, num_clusters):
128
  with gr.Blocks(title=TITLE) as demo:
129
  gr.Markdown(f"# {TITLE}")
130
  gr.Markdown(
131
- "## Explore the data generated from [DiffusionBiasExplorer](https://huggingface.co/spaces/society-ethics/DiffusionBiasExplorer)!"
132
- )
133
- gr.Markdown(
134
- "### This demo showcases patterns in the images generated from different prompts input to Stable Diffusion and Dalle-2 systems."
135
- )
136
- gr.Markdown(
137
- "### Below, see results on how the images from different prompts cluster together."
138
  )
139
  gr.HTML(
140
  """<span style="color:red" font-size:smaller>⚠️ DISCLAIMER: the images displayed by this tool were generated by text-to-image systems and may depict offensive stereotypes or contain explicit content.</span>"""
@@ -146,10 +133,8 @@ with gr.Blocks(title=TITLE) as demo:
146
  )
147
 
148
  with gr.Row():
149
- with gr.Column(scale=4):
150
- gallery = gr.Gallery(label="Most representative images in cluster").style(
151
- grid=(3, 3)
152
- )
153
  with gr.Column():
154
  cluster_id = gr.Dropdown(
155
  choices=[i for i in range(num_clusters.value)],
@@ -158,7 +143,7 @@ with gr.Blocks(title=TITLE) as demo:
158
  )
159
  a = gr.Text(label="Number of images")
160
  with gr.Row():
161
- with gr.Column(scale=1):
162
  c = gr.Plot(label="How many images from each system?")
163
  c_desc = gr.HTML(label="")
164
  with gr.Column(scale=1):
 
70
  img_path = "/".join(
71
  [st.replace("/", "") for st in cl_dct["img_path_list"][i].split("//")][3:]
72
  )
73
+ im = Image.open(os.path.join("identities-images", img_path))
74
+ #.resize((256, 256))
75
+ caption = "_".join([img_path.split("/")[0], img_path.split("/")[-1]]).replace("Photo_portrait_of_an_", "").replace("Photo_portrait_of_a_", "").replace("SD_v2_random_seeds_identity_", "(SD v.2) ").replace("dataset-identities-dalle2_", "(Dall-E 2) ").replace("SD_v1.4_random_seeds_identity_", "(SD v.1.4) ").replace("_", " ")
76
+ images.append((im,caption))
 
 
 
 
 
 
 
 
77
  model_fig = go.Figure()
78
  model_fig.add_trace(
79
  go.Pie(
 
120
  with gr.Blocks(title=TITLE) as demo:
121
  gr.Markdown(f"# {TITLE}")
122
  gr.Markdown(
123
+ "Explore the data generated from [DiffusionBiasExplorer](https://huggingface.co/spaces/society-ethics/DiffusionBiasExplorer)! This demo showcases patterns in the images generated from different prompts input to Stable Diffusion and Dalle-2 systems.")
124
+ gr.Markdown("See the results on how the images from different prompts cluster together below."
 
 
 
 
 
125
  )
126
  gr.HTML(
127
  """<span style="color:red" font-size:smaller>⚠️ DISCLAIMER: the images displayed by this tool were generated by text-to-image systems and may depict offensive stereotypes or contain explicit content.</span>"""
 
133
  )
134
 
135
  with gr.Row():
136
+ with gr.Column():
137
+ gallery = gr.Gallery(label="Most representative images in cluster").style(grid=[2,3], height="auto")
 
 
138
  with gr.Column():
139
  cluster_id = gr.Dropdown(
140
  choices=[i for i in range(num_clusters.value)],
 
143
  )
144
  a = gr.Text(label="Number of images")
145
  with gr.Row():
146
+ with gr.Column():
147
  c = gr.Plot(label="How many images from each system?")
148
  c_desc = gr.HTML(label="")
149
  with gr.Column(scale=1):