dror201031 commited on
Commit
f068274
verified
1 Parent(s): 05c86b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -3
app.py CHANGED
@@ -1,7 +1,29 @@
 
 
1
  import os
2
- import gradio as gr
3
- from huggingface_hub import login
4
- from transformers import pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  # 讛转讞讘专讜转 诇-Hugging Face 注诐 诪驻转讞 诪讛讙讚专讜转 讛住讜讚讜转
7
  token = os.environ.get("HF_TOKEN")
@@ -42,6 +64,7 @@ def ask_model(prompt):
42
  except Exception as e:
43
  return f"砖讙讬讗讛 讘拽讘诇转 转砖讜讘讛: {str(e)}"
44
 
 
45
  demo = gr.Interface(
46
  fn=ask_model,
47
  inputs=gr.Textbox(lines=3, placeholder="砖讗诇 砖讗诇讛..."),
@@ -50,4 +73,5 @@ demo = gr.Interface(
50
  description="爪'讗讟讘讜讟 诪讘讜住住 注诇 诪讜讚诇 Gemma 3n 砖诇 Google"
51
  )
52
 
 
53
  demo.launch()
 
1
+ import sys
2
+ import subprocess
3
  import os
4
+
5
+ # 讛转拽谞转 讞讘讬诇讜转 讞住专讜转
6
+ print("诪转拽讬谉 讞讘讬诇讜转 谞讚专砖讜转...")
7
+ try:
8
+ subprocess.check_call([sys.executable, "-m", "pip", "install",
9
+ "transformers>=4.38.0",
10
+ "huggingface_hub>=0.20.0",
11
+ "torch>=2.0.0",
12
+ "accelerate>=0.25.0",
13
+ "bitsandbytes>=0.40.0"])
14
+ print("讛转拽谞转 讛讞讘讬诇讜转 讛讜砖诇诪讛 讘讛爪诇讞讛!")
15
+ except Exception as e:
16
+ print(f"砖讙讬讗讛 讘讛转拽谞转 讛讞讘讬诇讜转: {str(e)}")
17
+
18
+ # 讬讘讜讗 砖诇 讛住驻专讬讜转 讛谞讚专砖讜转
19
+ try:
20
+ import gradio as gr
21
+ from huggingface_hub import login
22
+ from transformers import pipeline
23
+ print("讬讘讜讗 讛住驻专讬讜转 讛爪诇讬讞!")
24
+ except Exception as e:
25
+ print(f"砖讙讬讗讛 讘讬讘讜讗 讛住驻专讬讜转: {str(e)}")
26
+ sys.exit(1)
27
 
28
  # 讛转讞讘专讜转 诇-Hugging Face 注诐 诪驻转讞 诪讛讙讚专讜转 讛住讜讚讜转
29
  token = os.environ.get("HF_TOKEN")
 
64
  except Exception as e:
65
  return f"砖讙讬讗讛 讘拽讘诇转 转砖讜讘讛: {str(e)}"
66
 
67
+ # 讬爪讬专转 诪诪砖拽 讛诪砖转诪砖
68
  demo = gr.Interface(
69
  fn=ask_model,
70
  inputs=gr.Textbox(lines=3, placeholder="砖讗诇 砖讗诇讛..."),
 
73
  description="爪'讗讟讘讜讟 诪讘讜住住 注诇 诪讜讚诇 Gemma 3n 砖诇 Google"
74
  )
75
 
76
+ # 讛驻注诇转 讛诪诪砖拽
77
  demo.launch()