|
import importlib |
|
|
|
|
|
|
|
|
|
try: |
|
importlib.import_module('tensorflow') |
|
print("TensorFlow library is already installed") |
|
except ImportError: |
|
|
|
import subprocess |
|
subprocess.check_call(["pip", "install", "tensorflow"]) |
|
print("TensorFlow library has been installed") |
|
try: |
|
importlib.import_module('transformers') |
|
print("transformers library is already installed") |
|
except ImportError: |
|
|
|
import subprocess |
|
subprocess.check_call(["pip", "install", "transformers"]) |
|
print("transformers library has been installed") |
|
|
|
|
|
from transformers import pipeline |
|
|
|
|
|
generator = pipeline("mask-generation", device=0, points_per_batch=256) |
|
image_url = "https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png" |
|
outputs = generator(image_url, points_per_batch=256) |
|
|