Afrinetwork7 commited on
Commit
0f37f95
1 Parent(s): 2db8690

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -18
app.py CHANGED
@@ -4,7 +4,6 @@ import uuid
4
  from urllib.parse import quote
5
  from requests import get
6
  from bs4 import BeautifulSoup
7
- import hashlib
8
 
9
  import gradio as gr
10
  import numpy as np
@@ -79,8 +78,6 @@ def translate_to_english(phrase, src_lang):
79
 
80
 
81
  @spaces.GPU(enable_queue=True)
82
- CACHE_DIR = "image_cache"
83
-
84
  def generate(
85
  phrase: str,
86
  input_lang: str,
@@ -91,6 +88,7 @@ def generate(
91
  height: int = 1024,
92
  guidance_scale: float = 3,
93
  randomize_seed: bool = False,
 
94
  progress=gr.Progress(track_tqdm=True),
95
  ):
96
  pipe.to(device)
@@ -105,14 +103,6 @@ def generate(
105
  if not use_negative_prompt:
106
  negative_prompt = None # type: ignore
107
 
108
- # Hash the prompt and seed to create a unique cache key
109
- cache_key = hashlib.sha256(f"{prompt}{seed}".encode()).hexdigest()
110
-
111
- # Check if the image is already in the cache
112
- if os.path.exists(os.path.join(CACHE_DIR, f"{cache_key}.png")):
113
- print("Image found in cache")
114
- return [os.path.join(CACHE_DIR, f"{cache_key}.png")], seed
115
-
116
  images = pipe(
117
  prompt=prompt,
118
  negative_prompt=negative_prompt,
@@ -128,13 +118,6 @@ def generate(
128
 
129
  image_paths = [save_image(img) for img in images]
130
  print(image_paths)
131
-
132
- # Save the first image to the cache directory
133
- if not os.path.exists(CACHE_DIR):
134
- os.makedirs(CACHE_DIR)
135
- cache_path = os.path.join(CACHE_DIR, f"{cache_key}.png")
136
- Image.open(image_paths[0]).save(cache_path)
137
-
138
  return image_paths, seed
139
 
140
 
 
4
  from urllib.parse import quote
5
  from requests import get
6
  from bs4 import BeautifulSoup
 
7
 
8
  import gradio as gr
9
  import numpy as np
 
78
 
79
 
80
  @spaces.GPU(enable_queue=True)
 
 
81
  def generate(
82
  phrase: str,
83
  input_lang: str,
 
88
  height: int = 1024,
89
  guidance_scale: float = 3,
90
  randomize_seed: bool = False,
91
+ use_resolution_binning: bool = True,
92
  progress=gr.Progress(track_tqdm=True),
93
  ):
94
  pipe.to(device)
 
103
  if not use_negative_prompt:
104
  negative_prompt = None # type: ignore
105
 
 
 
 
 
 
 
 
 
106
  images = pipe(
107
  prompt=prompt,
108
  negative_prompt=negative_prompt,
 
118
 
119
  image_paths = [save_image(img) for img in images]
120
  print(image_paths)
 
 
 
 
 
 
 
121
  return image_paths, seed
122
 
123