jonathanagustin commited on
Commit
63d71fd
1 Parent(s): bcdc4f1

autoinstall requirements

Browse files
Files changed (1) hide show
  1. app.py +34 -7
app.py CHANGED
@@ -25,17 +25,44 @@ Run this file to launch the Gradio interface, which allows users to input search
25
 
26
  """
27
  import logging
 
 
28
  import sys
29
  from enum import Enum
30
  from typing import Any, Dict, List, Optional, Tuple
31
 
32
- import cv2
33
- import gradio as gr
34
- import innertube
35
- import numpy as np
36
- import streamlink
37
- from PIL import Image
38
- from ultralytics import YOLO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
41
 
 
25
 
26
  """
27
  import logging
28
+ import os
29
+ import subprocess
30
  import sys
31
  from enum import Enum
32
  from typing import Any, Dict, List, Optional, Tuple
33
 
34
+ import requests
35
+
36
+
37
+ def install_requirements():
38
+ requirements_url = "https://raw.githubusercontent.com/aai521-group6/project/main/requirements.txt"
39
+ response = requests.get(requirements_url)
40
+ if response.status_code == 200:
41
+ with open("requirements.txt", "wb") as file:
42
+ file.write(response.content)
43
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
44
+ else:
45
+ raise Exception("Failed to download requirements.txt")
46
+
47
+
48
+ try:
49
+ import cv2
50
+ import gradio as gr
51
+ import innertube
52
+ import numpy as np
53
+ import streamlink
54
+ from PIL import Image
55
+ from ultralytics import YOLO
56
+ except ImportError:
57
+ install_requirements()
58
+ import cv2
59
+ import gradio as gr
60
+ import innertube
61
+ import numpy as np
62
+ import streamlink
63
+ from PIL import Image
64
+ from ultralytics import YOLO
65
+
66
 
67
  logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
68