Spaces:
Runtime error
Runtime error
added progress bar for image generation
Browse files
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
|
| 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
|
| 30 |
-
#
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
image_demo = pipeline(prompt).images[0]
|
| 33 |
-
return image_demo
|
| 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:
|