sashavor commited on
Commit
44172c5
·
1 Parent(s): 2fe028c

starting to write the display function

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -1,15 +1,14 @@
1
  import gradio as gr
2
  import numpy as np
3
  import pandas as pd
4
- import json
5
 
6
  pd.options.plotting.backend = "plotly"
7
 
8
 
9
  TITLE = "Diffusion Faces Cluster Explorer"
10
- clusters_12 = json.load(open("clusters/professions_to_clusters_12.json"))
11
- clusters_24 = json.load(open("clusters/professions_to_clusters_24.json"))
12
- clusters_48 = json.load(open("clusters/professions_to_clusters_48.json"))
13
 
14
  clusters_by_size = {
15
  12: clusters_12,
@@ -26,6 +25,10 @@ adjectives.insert(0, '')
26
  professions = sorted([p.lower() for p in prompts['Occupation-Noun'].tolist()])
27
  models = ["Dall-E 2", "Stable Diffusion 1.4", "Stable Diffusion 2"]
28
 
 
 
 
 
29
 
30
  with gr.Blocks() as demo:
31
  gr.Markdown("# 🤗 Diffusion Cluster Explorer")
@@ -33,14 +36,15 @@ with gr.Blocks() as demo:
33
  with gr.Tab("Exploring all professions together"):
34
  gr.Markdown("TODO")
35
  with gr.Row():
36
- with gr.Column():
37
- gr.Markdown("Select your settings below:")
38
- num_clusters = gr.Radio([12,24,48], value=12, label="How many clusters do you want to make from the data?")
39
- professions = gr.Dropdown
40
- with gr.Column():
41
- gr.Markdown("")
42
- order = gr.Dropdown(["entropy", "cluster/sum of clusters"], value="entryopy", label="Order rows by:", interactive=True)
43
- # with gr.Row():
 
44
 
45
  # with gr.Accordion("Tag Frequencies", open=False):
46
 
 
1
  import gradio as gr
2
  import numpy as np
3
  import pandas as pd
 
4
 
5
  pd.options.plotting.backend = "plotly"
6
 
7
 
8
  TITLE = "Diffusion Faces Cluster Explorer"
9
+ clusters_12 = pd.read_json("clusters/professions_to_clusters_12.json")
10
+ clusters_24 = pd.read_json("clusters/professions_to_clusters_24.json")
11
+ clusters_48 = pd.read_json("clusters/professions_to_clusters_48.json")
12
 
13
  clusters_by_size = {
14
  12: clusters_12,
 
25
  professions = sorted([p.lower() for p in prompts['Occupation-Noun'].tolist()])
26
  models = ["Dall-E 2", "Stable Diffusion 1.4", "Stable Diffusion 2"]
27
 
28
+ def gen_df(num_clusters,model,profs):
29
+ if num_clusters == 12:
30
+ print(clusters_12.head())
31
+
32
 
33
  with gr.Blocks() as demo:
34
  gr.Markdown("# 🤗 Diffusion Cluster Explorer")
 
36
  with gr.Tab("Exploring all professions together"):
37
  gr.Markdown("TODO")
38
  with gr.Row():
39
+ with gr.Column(scale=1):
40
+ gr.Markdown("Select the parameters here:")
41
+ num_clusters = gr.Radio([12,24,48], value=12, label="How many clusters do you want to make from the data?", interactive=True)
42
+ model_choices = gr.Dropdown(models, value= ["Dall-E 2", "Stable Diffusion 1.4", "Stable Diffusion 2"], label="Which models do you want to compare?", multiselect=True, interactive= True)
43
+ profession_choices = gr.Dropdown(professions, value=["CEO", "social worker"], label= "Which professions do you want to compare?", multiselect=True, interactive=True)
44
+ with gr.Column(scale=3):
45
+ gr.Markdown("Select the ordering here:")
46
+ order = gr.Dropdown(["entropy", "cluster/sum of clusters"], value="entropy", label="Order rows by:", interactive=True)
47
+ num_clusters.change(fn=gen_df, inputs=[num_clusters,model_choices,profession_choices], outputs=None)
48
 
49
  # with gr.Accordion("Tag Frequencies", open=False):
50