Dileep7729 commited on
Commit
3788991
·
verified ·
1 Parent(s): 9282d8a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +59 -1
README.md CHANGED
@@ -10,7 +10,65 @@ license: apache-2.0
10
  metrics:
11
  - bleu
12
  library_name: transformers
 
 
13
  ---
14
  # My Fine-Tuned Image Captioning Model
15
 
16
- This model is a fine-tuned version of [Salesforce/blip-image-captioning-base](https://huggingface.co/Salesforce/blip-image-captioning-base) on a custom dataset. It generates captions for images based on the features in the image.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  metrics:
11
  - bleu
12
  library_name: transformers
13
+ datasets:
14
+ - phiyodr/coco2017
15
  ---
16
  # My Fine-Tuned Image Captioning Model
17
 
18
+ This model is a fine-tuned version of [Salesforce/blip-image-captioning-base](https://huggingface.co/Salesforce/blip-image-captioning-base) on a custom dataset. It generates captions for images based on the features in the image.
19
+
20
+
21
+ Model Summary
22
+ This model is an image captioning model developed for generating descriptive captions for images. Leveraging Hugging Face’s BLIP model (BlipProcessor and BlipForConditionalGeneration), it accepts an input image and outputs a coherent caption that describes the image’s contents.
23
+
24
+ Example:
25
+ Input: An image of a dog playing in a garden.
26
+
27
+ Output: "A dog is playing in a green garden."
28
+
29
+ Source Model
30
+ This image captioning model is based on the BLIP (Bootstrapping Language-Image Pretraining) model, which is widely used for tasks involving multimodal input, such as image and text. The model architecture is optimized for conditional image captioning.
31
+
32
+ Dataset
33
+ The model was fine-tuned using a custom dataset suitable for generating descriptive captions.
34
+
35
+ To use this model's inference endpoint, you will need the Hugging Face Inference API URL and an API token. Replace your_model_name with the name of the model (e.g., quadranttechnologies/Dileep_model) and YOUR_API_TOKEN with your Hugging Face API token.
36
+
37
+
38
+ Inference Endpoint
39
+ This model is hosted on Hugging Face and can be accessed via an inference endpoint, allowing users to generate captions for images by making an API call.
40
+
41
+ How to Use the Endpoint
42
+ To use this model's inference endpoint, you will need the Hugging Face Inference API URL and an API token. Replace quadranttechnologies/qhub-blip-image-captioning-finetuned with the name of the model and YOUR_API_TOKEN with your Hugging Face API token.
43
+
44
+
45
+ import requests
46
+
47
+ # Set your model URL and API token
48
+ API_URL = "https://api-inference.huggingface.co/models/quadranttechnologies/Dileep_model"
49
+ headers = {"Authorization": "Bearer YOUR_API_TOKEN"}
50
+
51
+ def generate_caption(image_path):
52
+ # Open the image and read its bytes
53
+ with open(image_path, "rb") as image_file:
54
+ image_bytes = image_file.read()
55
+
56
+ # Make a POST request to the API endpoint
57
+ response = requests.post(API_URL, headers=headers, files={"file": image_bytes})
58
+
59
+ # Handle response
60
+ if response.status_code == 200:
61
+ return response.json().get("generated_text", "No caption generated")
62
+ else:
63
+ return f"Error: {response.status_code} - {response.text}"
64
+
65
+ # Example usage
66
+ caption = generate_caption("path_to_your_image.jpg")
67
+ print("Generated Caption:", caption)
68
+
69
+
70
+ Explanation
71
+ API_URL: This is the endpoint URL for the model. Replace quadranttechnologies/Dileep_model with the actual model name if it’s different.
72
+ Authorization: To authenticate the request, use the Hugging Face API token in the headers.
73
+ POST Request: The image file is sent as a POST request to the endpoint, where the model processes it and returns a caption.
74
+ This endpoint makes it easy to integrate the model into various applications for automated image captioning tasks.