Sabse commited on
Commit
ef0a3b5
·
1 Parent(s): dad27ef

Add application file

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -1,12 +1,22 @@
 
 
 
1
  import os
 
2
  import subprocess
 
 
 
 
 
 
 
 
 
3
  import gradio as gr
4
  from fastai.learner import load_learner
5
  from fastai.vision.all import *
6
 
7
- # Install necessary packages
8
- subprocess.run(["pip", "install", "fastai", "gradio"])
9
-
10
  # Construct the absolute path to the large data file
11
  # Get the absolute path to the current script's directory
12
  current_directory = os.path.abspath(os.path.dirname(__file__))
 
1
+
2
+
3
+
4
  import os
5
+ import sys
6
  import subprocess
7
+
8
+ # Install necessary packages if not already installed
9
+ required_packages = ["fastai", "gradio"]
10
+ for package in required_packages:
11
+ try:
12
+ __import__(package)
13
+ except ImportError:
14
+ subprocess.run([sys.executable, "-m", "pip", "install", package])
15
+
16
  import gradio as gr
17
  from fastai.learner import load_learner
18
  from fastai.vision.all import *
19
 
 
 
 
20
  # Construct the absolute path to the large data file
21
  # Get the absolute path to the current script's directory
22
  current_directory = os.path.abspath(os.path.dirname(__file__))