ysharma HF staff commited on
Commit
e13c42d
1 Parent(s): 3166b97

update new layout

Browse files
Files changed (1) hide show
  1. app.py +41 -3
app.py CHANGED
@@ -8,13 +8,41 @@ import gradio as gr
8
  import pandas as pd
9
  from huggingface_hub import list_models
10
 
11
- # %% app.ipynb 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  def make_clickable_model(model_name, link=None):
13
  if link is None:
14
  link = "https://huggingface.co/" + model_name
15
- # Remove user from model name
16
- return f'<a target="_blank" href="{link}">{model_name.split("/")[-1]}</a>'
17
 
 
 
 
 
 
 
 
18
 
19
  def make_clickable_user(user_id):
20
  link = "https://huggingface.co/" + user_id
@@ -55,6 +83,9 @@ with block:
55
  For details on how to participate, check out the hackathon's guide [here](https://github.com/huggingface/diffusion-models-class/blob/main/hackathon/README.md).
56
  """
57
  )
 
 
 
58
  with gr.Tabs():
59
  with gr.TabItem("Animal 🐨"):
60
  with gr.Row():
@@ -66,6 +97,8 @@ with block:
66
  data_run.click(
67
  get_submissions, inputs=gr.Variable("animal"), outputs=animal_data
68
  )
 
 
69
  with gr.TabItem("Science 🔬"):
70
  with gr.Row():
71
  science_data = gr.components.Dataframe(
@@ -110,6 +143,11 @@ with block:
110
  inputs=gr.Variable("wildcard"),
111
  outputs=wildcard_data,
112
  )
 
 
 
 
 
113
 
114
  block.load(get_submissions, inputs=gr.Variable("animal"), outputs=animal_data)
115
  block.load(get_submissions, inputs=gr.Variable("science"), outputs=science_data)
 
8
  import pandas as pd
9
  from huggingface_hub import list_models
10
 
11
+ from diffusers import StableDiffusionPipeline
12
+
13
+ submissions_list = list_models(filter=["dreambooth-hackathon", category], full=True)
14
+ spaces_pipeline_load = [submission.id for submission in submissions_list ]
15
+ for ids in spaces_pipeline_load:
16
+ mydict[ids] = StableDiffusionPipeline.from_pretrained(ids) #('ashiqabdulkhader/shiba-dog')
17
+ #f"pipeline{ids.split('//')[-1]}" = StableDiffusionPipeline.from_pretrained(ids) #('ashiqabdulkhader/shiba-dog')
18
+
19
+ #pipeline = StableDiffusionPipeline.from_pretrained("ashiqabdulkhader/shiba-dog") #('pharma/sugar-glider')
20
+ #image = pipeline().images[0]
21
+ #image
22
+ #https://huggingface.co/ashiqabdulkhader/shiba-dog
23
+ def filter_species(species):
24
+ return gr.Dropdown.update(choices=species_map[species], value=species_map[species][1]), gr.update(visible=True)
25
+
26
+ # %% app.ipynb 1
27
+ def make_clickable_demo(model_name, prompt): #link=None):
28
+ #if link is None:
29
+ # link = "https://huggingface.co/" + model_name
30
+ # Remove user from model name
31
+ prompt = "a photo of " + ' '.join(model_name.split('/')[-1].split['-']) + str(prompt)
32
+
33
+ return gr.Button.update()
34
+
35
  def make_clickable_model(model_name, link=None):
36
  if link is None:
37
  link = "https://huggingface.co/" + model_name
 
 
38
 
39
+ #adding functionality for demo
40
+ prompt = "a photo of " + ' '.join(model_name.split('/')[-1].split['-']) + str(prompt)
41
+ pipeline = StableDiffusionPipeline.from_pretrained(model_name) #("ashiqabdulkhader/shiba-dog") #('pharma/sugar-glider')
42
+ image_demo = pipeline().images[0]
43
+
44
+ # Remove user from model name
45
+ return image_out.Update(value=image_demo, label=model_name.split("/")[-1]) #f'<a target="_blank" href="{link}">{model_name.split("/")[-1]}</a>'
46
 
47
  def make_clickable_user(user_id):
48
  link = "https://huggingface.co/" + user_id
 
83
  For details on how to participate, check out the hackathon's guide [here](https://github.com/huggingface/diffusion-models-class/blob/main/hackathon/README.md).
84
  """
85
  )
86
+ with gr.Row():
87
+ prompt_in = gr.Textbox(label="Type in a Prompt. This will be suffixed to 'a photo of <model name>', so prompt accordingly -")
88
+ #button_in = gr.Button(label = "Generate Image using this model")
89
  with gr.Tabs():
90
  with gr.TabItem("Animal 🐨"):
91
  with gr.Row():
 
97
  data_run.click(
98
  get_submissions, inputs=gr.Variable("animal"), outputs=animal_data
99
  )
100
+
101
+
102
  with gr.TabItem("Science 🔬"):
103
  with gr.Row():
104
  science_data = gr.components.Dataframe(
 
143
  inputs=gr.Variable("wildcard"),
144
  outputs=wildcard_data,
145
  )
146
+
147
+ with gr.Row() as your_model_demo :
148
+ image_out = gr.Image()
149
+
150
+ button_in.click(make_clickable_demo, prompt_in, your_model_demo)
151
 
152
  block.load(get_submissions, inputs=gr.Variable("animal"), outputs=animal_data)
153
  block.load(get_submissions, inputs=gr.Variable("science"), outputs=science_data)