John6666 commited on
Commit
c23cc05
1 Parent(s): e742cd8

Upload 8 files

Browse files
Files changed (2) hide show
  1. tagger/fl2flux.py +2 -2
  2. tagger/tagger.py +10 -1
tagger/fl2flux.py CHANGED
@@ -8,8 +8,8 @@ import subprocess
8
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
9
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
- fl_model = AutoModelForCausalLM.from_pretrained('gokaygokay/Florence-2-Flux', trust_remote_code=True).to("cpu").eval()
12
- fl_processor = AutoProcessor.from_pretrained('gokaygokay/Florence-2-Flux', trust_remote_code=True)
13
 
14
 
15
  def fl_modify_caption(caption: str) -> str:
 
8
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
9
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
+ fl_model = AutoModelForCausalLM.from_pretrained('gokaygokay/Florence-2-Flux-Large', trust_remote_code=True).to("cpu").eval()
12
+ fl_processor = AutoProcessor.from_pretrained('gokaygokay/Florence-2-Flux-Large', trust_remote_code=True)
13
 
14
 
15
  def fl_modify_caption(caption: str) -> str:
tagger/tagger.py CHANGED
@@ -189,7 +189,7 @@ def convert_danbooru_to_e621_prompt(input_prompt: str = "", prompt_type: str = "
189
 
190
  from translatepy import Translator
191
  translator = Translator()
192
- def translate_prompt(prompt: str = ""):
193
  def translate_to_english(input: str):
194
  try:
195
  output = str(translator.translate(input, 'English'))
@@ -218,6 +218,15 @@ def translate_prompt(prompt: str = ""):
218
  return ", ".join(outputs)
219
 
220
 
 
 
 
 
 
 
 
 
 
221
  def translate_prompt_to_ja(prompt: str = ""):
222
  def translate_to_japanese(input: str):
223
  try:
 
189
 
190
  from translatepy import Translator
191
  translator = Translator()
192
+ def translate_prompt_old(prompt: str = ""):
193
  def translate_to_english(input: str):
194
  try:
195
  output = str(translator.translate(input, 'English'))
 
218
  return ", ".join(outputs)
219
 
220
 
221
+ def translate_prompt(input: str):
222
+ try:
223
+ output = str(translator.translate(input, 'English'))
224
+ except Exception as e:
225
+ output = input
226
+ print(e)
227
+ return output
228
+
229
+
230
  def translate_prompt_to_ja(prompt: str = ""):
231
  def translate_to_japanese(input: str):
232
  try: