ysharma HF Staff commited on
Commit
2a9a6aa
·
1 Parent(s): 2d982ac
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -6,9 +6,10 @@ from io import BytesIO
6
  from diffusers import StableDiffusionUpscalePipeline
7
  import torch
8
  import os
 
9
 
10
  HF_TOKEN = os.environ.get('HF_TOKEN')
11
- client_if = Client("huggingface-projects/IF", hf_token=HF_TOKEN)
12
  client_pick = Client("yuvalkirstain/PickScore")
13
 
14
  # load upscaling model and scheduler
@@ -22,7 +23,8 @@ def get_IF_op(prompt, neg_prompt):
22
  folder_path = filepaths[0]
23
  file_list = os.listdir(folder_path)
24
  file_list = [os.path.join(folder_path, f) for f in file_list if f != 'captions.json']
25
- return file_list
 
26
 
27
  def get_pickscores(prompt, file_list):
28
  print("inside get_pickscores")
@@ -37,6 +39,7 @@ def get_pickscores(prompt, file_list):
37
 
38
  def get_upscale_op(prompt, gallery_if):
39
  print("inside get_upscale_op")
 
40
  # get pickscores
41
  best_match_image = get_pickscores(prompt, gallery_if)
42
  # let's get the best pick!
@@ -47,18 +50,18 @@ def get_upscale_op(prompt, gallery_if):
47
  #upscaled_image.save("upsampled.png")
48
  return upscaled_image
49
 
50
-
51
  with gr.Blocks() as demo:
52
  with gr.Row():
53
  with gr.Column():
54
  prompt = gr.Textbox(label='Prompt')
55
  neg_prompt = gr.Textbox(label='Negative Prompt')
56
  b1 = gr.Button('Generate')
57
- gallery_if = gr.Gallery(label='IF Space outputs')
 
58
  b2 = gr.Button("Get the best generation using Pick-A-Pic")
59
  image_picakapic = gr.Image(label="PickAPic Evaluated Output")
60
 
61
  b1.click(get_IF_op,[prompt, neg_prompt], gallery_if)
62
- b1.click(get_upscale_op,[prompt, gallery_if], image_picakapic)
63
 
64
  demo.launch(debug=True)
 
6
  from diffusers import StableDiffusionUpscalePipeline
7
  import torch
8
  import os
9
+ import requests
10
 
11
  HF_TOKEN = os.environ.get('HF_TOKEN')
12
+ client_if = Client("ysharma/IF", hf_token=HF_TOKEN)
13
  client_pick = Client("yuvalkirstain/PickScore")
14
 
15
  # load upscaling model and scheduler
 
23
  folder_path = filepaths[0]
24
  file_list = os.listdir(folder_path)
25
  file_list = [os.path.join(folder_path, f) for f in file_list if f != 'captions.json']
26
+ print(f"^^file list is: {file_list}")
27
+ return file_list
28
 
29
  def get_pickscores(prompt, file_list):
30
  print("inside get_pickscores")
 
39
 
40
  def get_upscale_op(prompt, gallery_if):
41
  print("inside get_upscale_op")
42
+ print(f"^^gallery_if is: {gallery_if}")
43
  # get pickscores
44
  best_match_image = get_pickscores(prompt, gallery_if)
45
  # let's get the best pick!
 
50
  #upscaled_image.save("upsampled.png")
51
  return upscaled_image
52
 
 
53
  with gr.Blocks() as demo:
54
  with gr.Row():
55
  with gr.Column():
56
  prompt = gr.Textbox(label='Prompt')
57
  neg_prompt = gr.Textbox(label='Negative Prompt')
58
  b1 = gr.Button('Generate')
59
+ with gr.Row():
60
+ gallery_if = gr.Gallery(label='IF Space outputs')
61
  b2 = gr.Button("Get the best generation using Pick-A-Pic")
62
  image_picakapic = gr.Image(label="PickAPic Evaluated Output")
63
 
64
  b1.click(get_IF_op,[prompt, neg_prompt], gallery_if)
65
+ b2.click(get_upscale_op,[prompt, gallery_if], image_picakapic)
66
 
67
  demo.launch(debug=True)