ysharma HF staff commited on
Commit
daaa9eb
1 Parent(s): 3fa1834

added progress bar for image generation

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -18,7 +18,7 @@ def get_model_list(category):
18
 
19
 
20
  def get_initial_prompt(model_nm):
21
- #a photo of peterj/shbrcky-dog
22
  user_model_nm = model_nm.split('/')[-1]
23
  if '-' in user_model_nm:
24
  prompt = " ".join(user_model_nm.split('-'))
@@ -26,12 +26,19 @@ def get_initial_prompt(model_nm):
26
  prompt = user_model_nm
27
  return gr.Textbox.update(value="a photo of " + prompt + " ")
28
 
29
- def make_demo(model_name, prompt): #link=None):
30
- #prompt = "a photo of " + ' '.join(model_name.split('/')[-1].split['-']) + str(prompt)
31
- pipeline = StableDiffusionPipeline.from_pretrained(model_name) #("ashiqabdulkhader/shiba-dog") #('pharma/sugar-glider')
 
 
 
 
 
 
 
 
32
  image_demo = pipeline(prompt).images[0]
33
- return image_demo #gr.Button.update()
34
-
35
 
36
  def make_clickable_model(model_name, link=None):
37
  if link is None:
 
18
 
19
 
20
  def get_initial_prompt(model_nm):
21
+ #Example - a photo of shbrcky dog
22
  user_model_nm = model_nm.split('/')[-1]
23
  if '-' in user_model_nm:
24
  prompt = " ".join(user_model_nm.split('-'))
 
26
  prompt = user_model_nm
27
  return gr.Textbox.update(value="a photo of " + prompt + " ")
28
 
29
+ def get_pipeline(model_name): #, progress=gr.Progress(track_tqdm=True)):
30
+ #Using diffusers pipeline to generate an image for the demo
31
+ #Loading Your Dreambooth model
32
+ pipeline = StableDiffusionPipeline.from_pretrained(model_name) # Example - ("ashiqabdulkhader/shiba-dog") or ('pharma/sugar-glider')
33
+ return pipeline
34
+
35
+ def make_demo(model_name, prompt, progress=gr.Progress(track_tqdm=True)):
36
+ #Using diffusers pipeline to generate an image for the demo
37
+ progress(0, desc="Starting...")
38
+ pipeline = get_pipeline(model_name) #StableDiffusionPipeline.from_pretrained(model_name) # Example - ("ashiqabdulkhader/shiba-dog") or ('pharma/sugar-glider')
39
+ #Generating Image from your prompt
40
  image_demo = pipeline(prompt).images[0]
41
+ return image_demo
 
42
 
43
  def make_clickable_model(model_name, link=None):
44
  if link is None: