haohsiang commited on
Commit
943faab
·
1 Parent(s): 6e94257

change lora, add OAuth button

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -22,13 +22,14 @@ client = OpenAI(api_key=api_key)
22
  # text to image 設定
23
  access_token = os.getenv('HF_TOKEN')
24
  model_id = "stabilityai/stable-diffusion-xl-base-1.0"
25
- pipe_t2i = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float16, use_safetensors=True, token=access_token).to("cuda")
26
- pipe_t2i.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe_t2i.scheduler.config)
27
 
28
- # 載入 LoRA 權重
29
- lora_path = "./tbh368-sdxl.safetensors"
30
- pipe_t2i.load_lora_weights(lora_path, adapter_name="milton-glaser")
31
- pipe_t2i.set_adapters(["milton-glaser"], adapter_weights=[1.0])
 
32
 
33
  # 載入 CVAW Corpus 資料
34
  cvaw_data = pd.read_csv('./CVAW_all_SD.csv', delimiter='\t')
@@ -124,7 +125,7 @@ def generate_images(history, conversation_times, last_genimg_times, generated_im
124
  last_genimg_times = conversation_times
125
 
126
  for i in range(4):
127
- img = pipe_t2i("style of Milton Glaser, healing image, "+prompt,
128
  negative_prompt=neg_prompt,
129
  height=720, width=512,
130
  generator=generator[i],
@@ -308,6 +309,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
308
  selected_image = gr.Image(interactive=False, show_share_button=False, label="你選擇的圖像")
309
  image_chat_input = gr.Textbox(label="這張圖像讓你產生了什麼樣的聯想?")
310
  image_chat_button = gr.Button("與聊天機器人分享", variant="primary")
 
311
 
312
  # chatbot events handle
313
  submit.click(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons, conversation_times, valence_scores, arousal_scores, meditation_flag])
 
22
  # text to image 設定
23
  access_token = os.getenv('HF_TOKEN')
24
  model_id = "stabilityai/stable-diffusion-xl-base-1.0"
25
+ pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float16, use_safetensors=True, token=access_token).to("cuda")
26
+ pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
27
 
28
+ # 載入 LoRA
29
+ # lora_path = "./tbh368-sdxl.safetensors"
30
+ # pipe.load_lora_weights(lora_path, adapter_name="milton-glaser")
31
+ # pipe.set_adapters(["milton-glaser"], adapter_weights=[1.0])
32
+ pipe.load_lora_weights("KappaNeuro/konstantin-korovin-style", weight_name="Konstantin Korovin Style.safetensors", adapter_name="impressionism")
33
 
34
  # 載入 CVAW Corpus 資料
35
  cvaw_data = pd.read_csv('./CVAW_all_SD.csv', delimiter='\t')
 
125
  last_genimg_times = conversation_times
126
 
127
  for i in range(4):
128
+ img = pipe("Konstantin Korovin Style - , "+prompt,
129
  negative_prompt=neg_prompt,
130
  height=720, width=512,
131
  generator=generator[i],
 
309
  selected_image = gr.Image(interactive=False, show_share_button=False, label="你選擇的圖像")
310
  image_chat_input = gr.Textbox(label="這張圖像讓你產生了什麼樣的聯想?")
311
  image_chat_button = gr.Button("與聊天機器人分享", variant="primary")
312
+ gr.LoginButton()
313
 
314
  # chatbot events handle
315
  submit.click(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons, conversation_times, valence_scores, arousal_scores, meditation_flag])