Hieucyber2208 commited on
Commit
e3ec604
·
verified ·
1 Parent(s): 575b75f

Update src/image_gen.py

Browse files
Files changed (1) hide show
  1. src/image_gen.py +3 -3
src/image_gen.py CHANGED
@@ -16,7 +16,7 @@ genai.configure(api_key=GOOGLE_API_KEY)
16
  client = InferenceClient(provider="hf-inference", api_key=HF_TOKEN)
17
 
18
  def split_text_for_images(number_of_images):
19
- with open("./data/text/text.txt", "r", encoding="utf-8") as file:
20
  text = file.read().strip()
21
 
22
  total_length = len(text)
@@ -101,7 +101,7 @@ def image_gen(number_of_images = 3,detail_level = "short", perspective="neutral"
101
  texts = split_text_for_images(number_of_images)
102
  index = 0
103
  for text in tqdm(texts, desc="Processing", unit="image"):
104
- output_path = f"./data/image/{index}.png"
105
  prompt = describe_image(text, detail_level, perspective, emotion, time_setting, art_style)
106
  print(prompt)
107
 
@@ -121,6 +121,6 @@ def image_gen(number_of_images = 3,detail_level = "short", perspective="neutral"
121
  print(f"Thử lại sau {wait_time:.2f} giây...")
122
  time.sleep(wait_time)
123
  index += 1
124
- os.remove("./data/text/text.txt")
125
  if __name__ == "__main__":
126
  image_gen(number_of_images = 3, detail_level="short", perspective="neutral", emotion="sad", time_setting="classic", art_style="realistic", style="anime", color_palette="monochrome")
 
16
  client = InferenceClient(provider="hf-inference", api_key=HF_TOKEN)
17
 
18
  def split_text_for_images(number_of_images):
19
+ with open("./text/text.txt", "r", encoding="utf-8") as file:
20
  text = file.read().strip()
21
 
22
  total_length = len(text)
 
101
  texts = split_text_for_images(number_of_images)
102
  index = 0
103
  for text in tqdm(texts, desc="Processing", unit="image"):
104
+ output_path = f"./image/{index}.png"
105
  prompt = describe_image(text, detail_level, perspective, emotion, time_setting, art_style)
106
  print(prompt)
107
 
 
121
  print(f"Thử lại sau {wait_time:.2f} giây...")
122
  time.sleep(wait_time)
123
  index += 1
124
+ os.remove("./text/text.txt")
125
  if __name__ == "__main__":
126
  image_gen(number_of_images = 3, detail_level="short", perspective="neutral", emotion="sad", time_setting="classic", art_style="realistic", style="anime", color_palette="monochrome")