Image Segmentation
Transformers
PyTorch
repcontur
feature-extraction
medical
radiology
ct
3d
tumor-segmentation
referring-segmentation
report-generation
visual-question-answering
custom_code
Instructions to use Oncosoft-Research/RepConTUR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Oncosoft-Research/RepConTUR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-segmentation", model="Oncosoft-Research/RepConTUR", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Oncosoft-Research/RepConTUR", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download _utils.py from Oncosoft-Research/RepConTUR: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/Oncosoft-Research/RepConTUR/resolve/refs%2Fpr%2F1/_utils.py
- Command line
-
hf download hf://Oncosoft-Research/RepConTUR@refs/pr/1/_utils.py
-
curl -L -o _utils.py https://huggingface.co/Oncosoft-Research/RepConTUR/resolve/refs%2Fpr%2F1/_utils.py
1.13 kB
| """Inference utilities vendored from xtuner (stop criteria + prompt template).""" | |
| from transformers import StoppingCriteria, StoppingCriteriaList | |
| PHI3_CHAT_TEMPLATE = { | |
| 'SYSTEM': '<|system|>\n{system}<|end|>\n', | |
| 'INSTRUCTION': '<|user|>\n{input}<|end|>\n<|assistant|>\n', | |
| 'SUFFIX': '<|end|>', | |
| 'SUFFIX_AS_EOS': True, | |
| 'SEP': '\n', | |
| 'STOP_WORDS': ['<|end|>'], | |
| } | |
| class StopWordStoppingCriteria(StoppingCriteria): | |
| """Stop generation once the decoded tail matches a stop word.""" | |
| def __init__(self, tokenizer, stop_word): | |
| self.tokenizer = tokenizer | |
| self.stop_word = stop_word | |
| self.length = len(stop_word) | |
| def __call__(self, input_ids, *args, **kwargs) -> bool: | |
| current_text = self.tokenizer.decode(input_ids[0]) | |
| current_text = current_text.replace('\r', '').replace('\n', '') | |
| return current_text[-self.length:] == self.stop_word | |
| def get_stop_criteria(tokenizer, stop_words=()): | |
| stop_criteria = StoppingCriteriaList() | |
| for word in stop_words: | |
| stop_criteria.append(StopWordStoppingCriteria(tokenizer, word)) | |
| return stop_criteria | |