nouamanetazi HF staff commited on
Commit
6ce55e7
·
verified ·
1 Parent(s): 4880c5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -3,6 +3,7 @@ import torch
3
  from transformers import pipeline
4
  import os
5
  import spaces
 
6
 
7
  #load_dotenv()
8
  key=os.environ["HF_KEY"]
@@ -24,8 +25,8 @@ print("[INFO] load model ...")
24
  pipe=load_model()
25
  print("[INFO] model loaded")
26
 
 
27
  @spaces.GPU
28
- @gr.cache(persist=True) # Add persistent caching
29
  def predict(text):
30
  outputs = pipe(text)
31
  scores= [x["score"] for x in outputs]
@@ -52,7 +53,7 @@ with gr.Blocks() as demo:
52
  gr.Examples(
53
  examples=["العاصمة د <mask> هي الرباط","المغرب <mask> زوين","انا سميتي مريم، و كنسكن ف<mask> العاصمة دفلسطين"],
54
  inputs=input_text,
55
- cache_examples=True,
56
  preprocess=True # Precompute examples
57
  )
58
 
@@ -60,7 +61,7 @@ with gr.Blocks() as demo:
60
  # Output probabilities
61
  output_labels = gr.Label(
62
  label="Prediction Results",
63
- show_label=False,
64
  num_top_classes=5 # Limit to top 5 predictions
65
  )
66
 
@@ -79,4 +80,4 @@ with gr.Blocks() as demo:
79
 
80
  # Launch the app with queue
81
  demo.queue(concurrency_count=3) # Allow 3 concurrent predictions
82
- demo.launch(show_api=False) # Disable API tab if not needed
 
3
  from transformers import pipeline
4
  import os
5
  import spaces
6
+ import functools
7
 
8
  #load_dotenv()
9
  key=os.environ["HF_KEY"]
 
25
  pipe=load_model()
26
  print("[INFO] model loaded")
27
 
28
+ # Remove the @gr.cache decorator since it's not available
29
  @spaces.GPU
 
30
  def predict(text):
31
  outputs = pipe(text)
32
  scores= [x["score"] for x in outputs]
 
53
  gr.Examples(
54
  examples=["العاصمة د <mask> هي الرباط","المغرب <mask> زوين","انا سميتي مريم، و كنسكن ف<mask> العاصمة دفلسطين"],
55
  inputs=input_text,
56
+ cache_examples=True
57
  preprocess=True # Precompute examples
58
  )
59
 
 
61
  # Output probabilities
62
  output_labels = gr.Label(
63
  label="Prediction Results",
64
+ show_label=False
65
  num_top_classes=5 # Limit to top 5 predictions
66
  )
67
 
 
80
 
81
  # Launch the app with queue
82
  demo.queue(concurrency_count=3) # Allow 3 concurrent predictions
83
+ demo.launch() # Remove show_api parameter if it causes issues