Instructions to use AndreCosta/resnet-unet-segmentation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AndreCosta/resnet-unet-segmentation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-segmentation", model="AndreCosta/resnet-unet-segmentation")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AndreCosta/resnet-unet-segmentation", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 977 Bytes
7b615ae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #encoding=utf8
import os
from PIL import Image
import scripts.config as config
target = config.masks
extension_destination = '.png'
print('Starting processing...')
files = os.listdir(target)
for fileOne in files:
nameFile, extension = os.path.splitext(fileOne)
print('Testing: ', fileOne)
if((extension != extension_destination) and
(extension != '.json')):
if(extension == ''):
extension = '....'
print('\nRenaming: ' + str(fileOne))
origem = os.path.join(target, fileOne)
destino = fileOne.replace(extension, extension_destination)
if(extension == '....'):
destino = destino + extension_destination
destino = os.path.join(target, destino)
im = Image.open(origem).convert('RGB')
im.save(destino, 'PNG')
os.remove(origem)
print('-----------------------------------------')
print('\n\nCompleted...')
|