amangoyal05 commited on
Commit
21fd9ba
·
verified ·
1 Parent(s): b90bc53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -3,8 +3,28 @@ import os
3
  import base64
4
  import threading
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # Import the generation wrapper
7
- from gen import setup_translation, translate_text as gen_translate
8
 
9
  # Logo and favicon setup
10
  LOGO_PATH = "static/logo.png"
 
3
  import base64
4
  import threading
5
 
6
+ login(token=os.environ["HF_TOKEN"])
7
+ repo_id = os.environ["REPO_ID"]
8
+
9
+ # Torch optimizations
10
+ import torch
11
+ torch.set_num_threads(1)
12
+ if torch.cuda.is_available():
13
+ torch.backends.cudnn.benchmark = True
14
+
15
+ # Download generation logic from private repo
16
+ try:
17
+ generate_file = hf_hub_download(
18
+ repo_id=repo_id,
19
+ filename="gen1.py",
20
+ token=os.environ["HF_TOKEN"]
21
+ )
22
+ os.system(f"cp {generate_file} ./gen1.py")
23
+ except Exception as e:
24
+ print(f"Error downloading files: {e}")
25
+
26
  # Import the generation wrapper
27
+ from gen1 import setup_translation, translate_text as gen_translate
28
 
29
  # Logo and favicon setup
30
  LOGO_PATH = "static/logo.png"