Keltezaa commited on
Commit
1a77a75
·
verified ·
1 Parent(s): 208cc61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -15,7 +15,18 @@ import random
15
  import time
16
  import requests
17
  import pandas as pd
18
- #multimodalart/flux-lora-lab - do not edit
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  #Load prompts for randomization
21
  df = pd.read_csv('prompts.csv', header=None)
@@ -48,6 +59,15 @@ MAX_SEED = 2**32 - 1
48
 
49
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
50
 
 
 
 
 
 
 
 
 
 
51
  class calculateDuration:
52
  def __init__(self, activity_name=""):
53
  self.activity_name = activity_name
 
15
  import time
16
  import requests
17
  import pandas as pd
18
+
19
+ # Disable tokenizer parallelism
20
+ os.environ["TOKENIZERS_PARALLELISM"] = "false"
21
+
22
+ # Initialize the CLIP tokenizer and model
23
+ clip_tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-base-patch16")
24
+ clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch16")
25
+ clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch16")
26
+
27
+ # Initialize the Longformer tokenizer and model
28
+ longformer_tokenizer = LongformerTokenizer.from_pretrained("allenai/longformer-base-4096")
29
+ longformer_model = LongformerModel.from_pretrained("allenai/longformer-base-4096")
30
 
31
  #Load prompts for randomization
32
  df = pd.read_csv('prompts.csv', header=None)
 
59
 
60
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
61
 
62
+ def process_input(input_text):
63
+ # Tokenize and truncate input
64
+ inputs = clip_processor(text=input_text, return_tensors="pt", padding=True, truncation=True, max_length=77)
65
+ return inputs
66
+
67
+ # Example usage
68
+ input_text = "Your long prompt goes here..."
69
+ inputs = process_input(input_text)
70
+
71
  class calculateDuration:
72
  def __init__(self, activity_name=""):
73
  self.activity_name = activity_name