I built a simple clip model using pytorch and uploaded to huggingface manually, I want to use it with transformer library, I added a config json file but when i try to load to model it throws not valid json file error:
from transformers import CLIPProcessor, CLIPModel
model_identifier = 'umarigan/turkish_clip'
processor = CLIPProcessor.from_pretrained(model_identifier)
model = CLIPModel.from_pretrained(model_identifier)
text = ["a black watch"]
image = "/content/download (3).png"
inputs = processor(text, images=image, return_tensors="pt")
outputs = model(**inputs)
# For CLIP, assuming outputs are embeddings for text and image
text_embedding = outputs.logits_per_image
image_embedding = outputs.logits_per_text
text_embedding @ image_embedding.T
config file:
custom_config = {
"_class_name": "CLIPModel",
"_name_or_path": "custom-clip-model",
"temperature": 1.0,
"image_embedding": 2048,
"text_embedding": 768,
"image_encoder": {
"_class_name": "ImageEncoder",
"model_name": "resnet50",
"pretrained": True,
"trainable": True
},
"text_encoder": {
"_class_name": "TextEncoder",
"model_name": "distilbert-base-multilingual-cased",
"pretrained": True,
"trainable": True
},
"image_projection": {
"_class_name": "ProjectionHead",
"embedding_dim": 2048,
"projection_dim": 256,
"dropout": 0.1
},
"text_projection": {
"_class_name": "ProjectionHead",
"embedding_dim": 768,
"projection_dim": 256,
"dropout": 0.1
}
}
error:
preprocessor_config.json: 100%
943/943 [00:00<00:00, 2.70kB/s]
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/image_processing_utils.py in get_image_processor_dict(cls, pretrained_model_name_or_path, **kwargs)
361 text = reader.read()
--> 362 image_processor_dict = json.loads(text)
363
7 frames
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/image_processing_utils.py in get_image_processor_dict(cls, pretrained_model_name_or_path, **kwargs)
363
364 except json.JSONDecodeError:
--> 365 raise EnvironmentError(
366 f"It looks like the config file at '{resolved_image_processor_file}' is not a valid JSON file."
367 )
OSError: It looks like the config file at '/root/.cache/huggingface/hub/models--umarigan--turkish_clip/snapshots/815437d8cd928926006f910b24d9e51a06d52bf0/preprocessor_config.json' is not a valid JSON file.```
how to adjust a config file for such model?