arjunanand13 commited on
Commit
f37920f
·
verified ·
1 Parent(s): 137b217

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +3 -18
handler.py CHANGED
@@ -8,27 +8,12 @@ import requests
8
  from transformers import AutoModelForCausalLM, AutoProcessor
9
  import os
10
 
11
- def create_venv(venv_path="env"):
12
- """Creates a virtual environment."""
13
- if not os.path.exists(venv_path):
14
- print(f"[INFO] Creating virtual environment at {venv_path}")
15
- subprocess.check_call([sys.executable, "-m", "venv", venv_path])
16
- else:
17
- print(f"[INFO] Virtual environment already exists at {venv_path}")
18
-
19
- def install(package, venv_path="env"):
20
- """Installs a package inside the virtual environment."""
21
- pip_path = os.path.join(venv_path, "bin", "pip")
22
- subprocess.check_call([pip_path, "install", "--no-warn-script-location", package])
23
 
24
  class EndpointHandler:
25
  def __init__(self, path=""):
26
- # Step 1: Create the virtual environment
27
- self.venv_path = "env"
28
- create_venv(self.venv_path)
29
-
30
- # Step 2: Install required packages inside the virtual environment
31
- required_packages = ['timm', 'einops', 'flash-attn', 'Pillow']
32
  for package in required_packages:
33
  try:
34
  install(package, self.venv_path)
 
8
  from transformers import AutoModelForCausalLM, AutoProcessor
9
  import os
10
 
11
+ def install(package):
12
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "--no-warn-script-location", package])
 
 
 
 
 
 
 
 
 
 
13
 
14
  class EndpointHandler:
15
  def __init__(self, path=""):
16
+ required_packages = ['timm', 'einops', 'flash-attn', 'Pillow','transformers==4.44.0']
 
 
 
 
 
17
  for package in required_packages:
18
  try:
19
  install(package, self.venv_path)