# Creating valid json file for pytorch model

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreating-valid-json-file-for-pytorch-model%2F69889%3E%5C
**Category:** Models\
**Created:** [January 20, 2024, 12:50pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreating-valid-json-file-for-pytorch-model%2F69889 "2024-01-20T12:50:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![umarigan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/umarigan/32/18253_2.png) [@umarigan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fumarigan)%5C
**Post date:** [January 20, 2024, 12:50pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreating-valid-json-file-for-pytorch-model%2F69889%2F1 "2024-01-20T12:50:43Z")

</div>

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:

```auto
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:

```auto
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:

````auto
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?
````
