Clone04 commited on
Commit
7162cc7
·
verified ·
1 Parent(s): 64a5f0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,11 +1,16 @@
1
  import gradio as gr
2
  from optimum.intel import OVDiffusionPipeline
3
- import torch
4
  from threading import Lock
5
 
6
- # Load the pipeline globally
7
  model_id = "OpenVINO/FLUX.1-schnell-int4-ov"
8
  pipeline = OVDiffusionPipeline.from_pretrained(model_id, device="CPU")
 
 
 
 
 
9
  lock = Lock()
10
 
11
  # Define the image generation function
@@ -25,6 +30,6 @@ interface = gr.Interface(
25
  cache_examples=False
26
  )
27
 
28
- # Launch the interface with queueing
29
  if __name__ == "__main__":
30
- interface.launch(queue=True)
 
1
  import gradio as gr
2
  from optimum.intel import OVDiffusionPipeline
3
+ from transformers import AutoTokenizer
4
  from threading import Lock
5
 
6
+ # Load the pipeline and tokenizer globally
7
  model_id = "OpenVINO/FLUX.1-schnell-int4-ov"
8
  pipeline = OVDiffusionPipeline.from_pretrained(model_id, device="CPU")
9
+
10
+ # Explicitly load the tokenizer with fast settings
11
+ tokenizer = AutoTokenizer.from_pretrained("t5-v1_1-xxl", use_fast=True, add_prefix_space=True)
12
+ pipeline.text_encoder_2.tokenizer = tokenizer # Assign the tokenizer to the T5 encoder
13
+
14
  lock = Lock()
15
 
16
  # Define the image generation function
 
30
  cache_examples=False
31
  )
32
 
33
+ # Launch the interface
34
  if __name__ == "__main__":
35
+ interface.launch() # Removed queue=True for compatibility