- __pycache__/handler.cpython-310.pyc +0 -0
- __pycache__/test.cpython-310.pyc +0 -0
- handler.py +3 -38
- test.py +34 -0
__pycache__/handler.cpython-310.pyc
ADDED
|
Binary file (1.14 kB). View file
|
|
|
__pycache__/test.cpython-310.pyc
ADDED
|
Binary file (2.71 kB). View file
|
|
|
handler.py
CHANGED
|
@@ -4,52 +4,17 @@ import torch
|
|
| 4 |
import requests
|
| 5 |
from PIL import Image
|
| 6 |
from io import BytesIO
|
| 7 |
-
|
| 8 |
-
just_get_sd_mask_function = None
|
| 9 |
|
| 10 |
print(os.listdir('/usr/local/'))
|
| 11 |
print(torch.version.cuda)
|
| 12 |
|
| 13 |
class EndpointHandler():
|
| 14 |
def __init__(self, path="."):
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
is_production = True
|
| 18 |
-
|
| 19 |
-
if False:
|
| 20 |
-
return
|
| 21 |
-
|
| 22 |
-
os.chdir(path)
|
| 23 |
-
|
| 24 |
-
os.environ['AM_I_DOCKER'] = 'False'
|
| 25 |
-
os.environ['BUILD_WITH_CUDA'] = 'True'
|
| 26 |
-
os.environ['CUDA_HOME'] = '/usr/local/cuda-11.7/' if is_production else '/usr/local/cuda-12.1/'
|
| 27 |
-
|
| 28 |
-
# Install Segment Anything
|
| 29 |
-
subprocess.run(["python", "-m", "pip", "install", "-e", "segment_anything"])
|
| 30 |
-
|
| 31 |
-
# Install Grounding DINO
|
| 32 |
-
subprocess.run(["python", "-m", "pip", "install", "-e", "GroundingDINO"])
|
| 33 |
-
|
| 34 |
-
subprocess.run("wget https://huggingface.co/Uminosachi/sam-hq/resolve/main/sam_hq_vit_h.pth -O ./sam_hq_vit_h.pth", shell=True)
|
| 35 |
-
|
| 36 |
-
# Install diffusers
|
| 37 |
-
subprocess.run(["pip", "install", "--upgrade", "diffusers[torch]"])
|
| 38 |
-
|
| 39 |
-
# Install osx
|
| 40 |
-
subprocess.run(["git", "submodule", "update", "--init", "--recursive"])
|
| 41 |
-
subprocess.run(["bash", "grounded-sam-osx/install.sh"], cwd="grounded-sam-osx")
|
| 42 |
-
|
| 43 |
-
# Install RAM & Tag2Text
|
| 44 |
-
subprocess.run(["git", "clone", "https://github.com/xinyu1205/recognize-anything.git"])
|
| 45 |
-
subprocess.run(["pip", "install", "-r", "./recognize-anything/requirements.txt"])
|
| 46 |
-
subprocess.run(["pip", "install", "-e", "./recognize-anything/"])
|
| 47 |
-
|
| 48 |
-
from test import just_get_sd_mask
|
| 49 |
-
just_get_sd_mask_function = just_get_sd_mask
|
| 50 |
|
| 51 |
def __call__(self, data):
|
| 52 |
-
mask_pil =
|
| 53 |
|
| 54 |
if mask_pil.mode != 'RGB':
|
| 55 |
mask_pil = mask_pil.convert('RGB')
|
|
|
|
| 4 |
import requests
|
| 5 |
from PIL import Image
|
| 6 |
from io import BytesIO
|
| 7 |
+
from test import just_get_sd_mask
|
|
|
|
| 8 |
|
| 9 |
print(os.listdir('/usr/local/'))
|
| 10 |
print(torch.version.cuda)
|
| 11 |
|
| 12 |
class EndpointHandler():
|
| 13 |
def __init__(self, path="."):
|
| 14 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
def __call__(self, data):
|
| 17 |
+
mask_pil = just_get_sd_mask(Image.open("assets/demo1.jpg"), "bear", 10)
|
| 18 |
|
| 19 |
if mask_pil.mode != 'RGB':
|
| 20 |
mask_pil = mask_pil.convert('RGB')
|
test.py
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from grounded_sam_demo import grounded_sam_demo
|
| 2 |
import numpy as np
|
| 3 |
from PIL import Image
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
import torch
|
| 4 |
+
import requests
|
| 5 |
+
from PIL import Image
|
| 6 |
+
from io import BytesIO
|
| 7 |
+
|
| 8 |
+
is_production = True
|
| 9 |
+
|
| 10 |
+
os.chdir("/repository" if is_production else ".")
|
| 11 |
+
os.environ['AM_I_DOCKER'] = 'False'
|
| 12 |
+
os.environ['BUILD_WITH_CUDA'] = 'True'
|
| 13 |
+
os.environ['CUDA_HOME'] = '/usr/local/cuda-11.7/' if is_production else '/usr/local/cuda-12.1/'
|
| 14 |
+
|
| 15 |
+
# Install Segment Anything
|
| 16 |
+
subprocess.run(["python", "-m", "pip", "install", "-e", "segment_anything"])
|
| 17 |
+
|
| 18 |
+
# Install Grounding DINO
|
| 19 |
+
subprocess.run(["python", "-m", "pip", "install", "-e", "GroundingDINO"])
|
| 20 |
+
|
| 21 |
+
subprocess.run("wget https://huggingface.co/Uminosachi/sam-hq/resolve/main/sam_hq_vit_h.pth -O ./sam_hq_vit_h.pth", shell=True)
|
| 22 |
+
|
| 23 |
+
# Install diffusers
|
| 24 |
+
subprocess.run(["pip", "install", "--upgrade", "diffusers[torch]"])
|
| 25 |
+
|
| 26 |
+
# Install osx
|
| 27 |
+
subprocess.run(["git", "submodule", "update", "--init", "--recursive"])
|
| 28 |
+
subprocess.run(["bash", "grounded-sam-osx/install.sh"], cwd="grounded-sam-osx")
|
| 29 |
+
|
| 30 |
+
# Install RAM & Tag2Text
|
| 31 |
+
subprocess.run(["git", "clone", "https://github.com/xinyu1205/recognize-anything.git"])
|
| 32 |
+
subprocess.run(["pip", "install", "-r", "./recognize-anything/requirements.txt"])
|
| 33 |
+
subprocess.run(["pip", "install", "-e", "./recognize-anything/"])
|
| 34 |
+
|
| 35 |
from grounded_sam_demo import grounded_sam_demo
|
| 36 |
import numpy as np
|
| 37 |
from PIL import Image
|