Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,34 @@
|
|
1 |
-
"""pip install gradio
|
2 |
-
pip install openai
|
3 |
-
pip install PyPDF2
|
4 |
-
pip install tiktoken
|
5 |
-
pip install python-pptx
|
6 |
-
apt-get install git"""
|
7 |
-
import gradio as gr
|
8 |
-
|
9 |
-
git clone https://github.com/facebookresearch/segment-anything-2
|
10 |
%cd /content/segment-anything-2
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
|
|
|
|
|
|
17 |
wget -O sam2_hiera_small.pt "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_small.pt"
|
18 |
wget -O sam2_hiera_base_plus.pt "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_base_plus.pt"
|
19 |
wget -O sam2_hiera_large.pt "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_large.pt"
|
|
|
20 |
|
21 |
-
import os
|
22 |
-
|
23 |
import numpy as np
|
24 |
import pandas as pd
|
25 |
import cv2
|
@@ -45,12 +54,11 @@ from time import sleep
|
|
45 |
from csv import writer
|
46 |
from tqdm import tqdm
|
47 |
from scipy import spatial
|
48 |
-
from pptx import Presentation
|
49 |
from PyPDF2 import PdfReader
|
50 |
from openai import OpenAI
|
51 |
from IPython.display import display, Markdown, Latex, HTML
|
52 |
from transformers import GPT2Tokenizer
|
53 |
-
#from transformers import AutoTokenizer
|
54 |
from google.colab import files # for uploading files
|
55 |
from termcolor import colored # for colored text output
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
%cd /content/segment-anything-2
|
2 |
|
3 |
+
import os
|
4 |
+
import urllib.request
|
5 |
+
|
6 |
+
model_urls = {
|
7 |
+
"sam2_hiera_tiny.pt": "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_tiny.pt",
|
8 |
+
"sam2_hiera_small.pt": "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_small.pt",
|
9 |
+
"sam2_hiera_base_plus.pt": "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_base_plus.pt",
|
10 |
+
"sam2_hiera_large.pt": "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_large.pt",
|
11 |
+
}
|
12 |
+
|
13 |
+
def download_models():
|
14 |
+
for filename, url in model_urls.items():
|
15 |
+
if not os.path.exists(filename):
|
16 |
+
print(f"Downloading {filename}...")
|
17 |
+
urllib.request.urlretrieve(url, filename)
|
18 |
+
else:
|
19 |
+
print(f"{filename} already exists, skipping download.")
|
20 |
|
21 |
+
# Call it at startup
|
22 |
+
download_models()
|
23 |
+
|
24 |
+
"""wget -O sam2_hiera_tiny.pt "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_tiny.pt"
|
25 |
wget -O sam2_hiera_small.pt "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_small.pt"
|
26 |
wget -O sam2_hiera_base_plus.pt "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_base_plus.pt"
|
27 |
wget -O sam2_hiera_large.pt "https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_large.pt"
|
28 |
+
"""
|
29 |
|
30 |
+
#import os
|
31 |
+
import gradio as gr
|
32 |
import numpy as np
|
33 |
import pandas as pd
|
34 |
import cv2
|
|
|
54 |
from csv import writer
|
55 |
from tqdm import tqdm
|
56 |
from scipy import spatial
|
57 |
+
from pptx import Presentation
|
58 |
from PyPDF2 import PdfReader
|
59 |
from openai import OpenAI
|
60 |
from IPython.display import display, Markdown, Latex, HTML
|
61 |
from transformers import GPT2Tokenizer
|
|
|
62 |
from google.colab import files # for uploading files
|
63 |
from termcolor import colored # for colored text output
|
64 |
|