DiningSystem commited on
Commit
4a82c6c
1 Parent(s): 571dd64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -3,9 +3,21 @@ from diffusers import StableDiffusionPipeline
3
  import torch
4
  import huggingface_hub as hf
5
  import os
 
 
 
 
 
 
 
 
 
 
 
 
6
  hf.login(token=os.environ['model_token'])
7
  #remember to login with token before loading model
8
- def text_to_hair(prompt, guidance_scale=8, num_inference_steps=30, model_path ="CVH-vn1210/hair-model"):
9
 
10
  pipe = StableDiffusionPipeline.from_pretrained(os.environ['bmd'], torch_dtype=torch.float16, use_auth_token=True)
11
  pipe.unet.load_attn_procs(model_path)
@@ -14,5 +26,8 @@ def text_to_hair(prompt, guidance_scale=8, num_inference_steps=30, model_path ="
14
  #image.save(save_name) #comment if don't want to save image
15
  return image #PIL format
16
 
17
- demo = gr.Interface(fn=text_to_hair, inputs=["text", gr.Slider(5, 20, value=8, label="Guidance_scale", info="Choose between 5 and 20 to improve image's content"), gr.Slider(20, 500, value=20, label="Num_infer_steps", info="Choose between 20 and 500 to improve image's resolution")], outputs="image")
 
 
 
18
  demo.launch()
 
3
  import torch
4
  import huggingface_hub as hf
5
  import os
6
+
7
+ my_file = open("./style_name.txt", "r")
8
+
9
+ # reading the file
10
+ data = my_file.read()
11
+
12
+ # replacing end splitting the text
13
+ # when newline ('\n') is seen.
14
+ data_into_list = data.split("\n")[:-1]
15
+
16
+ my_file.close()
17
+
18
  hf.login(token=os.environ['model_token'])
19
  #remember to login with token before loading model
20
+ def text_to_hair(prompt, guidance_scale=8, num_inference_steps=30, styles, model_path ="CVH-vn1210/hair-model"):
21
 
22
  pipe = StableDiffusionPipeline.from_pretrained(os.environ['bmd'], torch_dtype=torch.float16, use_auth_token=True)
23
  pipe.unet.load_attn_procs(model_path)
 
26
  #image.save(save_name) #comment if don't want to save image
27
  return image #PIL format
28
 
29
+ demo = gr.Interface(fn=text_to_hair, inputs=["text", gr.Slider(5, 20, value=8, label="Guidance_scale", info="Choose between 5 and 20 to improve image's content"),
30
+ gr.Slider(20, 500, value=20, label="Num_infer_steps", info="Choose between 20 and 500 to improve image's resolution"),
31
+ gr.Dropdown(data_into_list, label="Some suggestion hairstyles", info="For your suggestion and reference!")],
32
+ outputs="image")
33
  demo.launch()