Arkan0ID commited on
Commit
38ba3f0
·
1 Parent(s): 4ed6c90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import huggingface_hub
2
- huggingface_hub.login('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')
 
 
3
 
4
  ###
5
 
@@ -26,6 +28,8 @@ processor = CLIPProcessor.from_pretrained('openai/clip-vit-large-patch14')
26
 
27
  import gradio as gr
28
  import numpy as np
 
 
29
 
30
  def inference(prompt, negative_prompt, num_samples, height, width, num_inference_steps, guidance_scale, seed, top_k):
31
  g_cuda = torch.Generator(DEVICE)
@@ -33,7 +37,7 @@ def inference(prompt, negative_prompt, num_samples, height, width, num_inference
33
  with torch.autocast(DEVICE), torch.inference_mode():
34
  images = pipe(
35
  prompt, height=int(height), width=int(width),
36
- negative_prompt=negative_prompt,
37
  num_images_per_prompt=int(num_samples),
38
  num_inference_steps=int(num_inference_steps),
39
  guidance_scale=guidance_scale,
@@ -52,7 +56,7 @@ with gr.Blocks() as demo:
52
  with gr.Row():
53
  with gr.Column():
54
  prompt = gr.Textbox(label='Prompt', value='photo of <Dmitry> <thumbs-up>')
55
- negative_prompt = gr.Textbox(label='Negative Prompt', value='ugly nerd with distorted fingers')
56
  run = gr.Button(value='Generate')
57
  guidance_scale = gr.Number(label='Guidance Scale', value=7.5)
58
  with gr.Row():
 
1
  import huggingface_hub
2
+ import os
3
+ hf_token = os.getenv('HF_TOKEN')
4
+ huggingface_hub.login(hf_token)
5
 
6
  ###
7
 
 
28
 
29
  import gradio as gr
30
  import numpy as np
31
+ from torch.nn.functional import cosine_similarity
32
+
33
 
34
  def inference(prompt, negative_prompt, num_samples, height, width, num_inference_steps, guidance_scale, seed, top_k):
35
  g_cuda = torch.Generator(DEVICE)
 
37
  with torch.autocast(DEVICE), torch.inference_mode():
38
  images = pipe(
39
  prompt, height=int(height), width=int(width),
40
+ negative_prompt='ugly nerd with distorted fingers' + negative_prompt,
41
  num_images_per_prompt=int(num_samples),
42
  num_inference_steps=int(num_inference_steps),
43
  guidance_scale=guidance_scale,
 
56
  with gr.Row():
57
  with gr.Column():
58
  prompt = gr.Textbox(label='Prompt', value='photo of <Dmitry> <thumbs-up>')
59
+ negative_prompt = gr.Textbox(label='Negative Prompt', value='')
60
  run = gr.Button(value='Generate')
61
  guidance_scale = gr.Number(label='Guidance Scale', value=7.5)
62
  with gr.Row():