Closed Barshan-Mandal closed 1 month ago
Here's a simple example of how you can use the Phi-3 Vision model with a planner in C#:
Install the necessary packages:
Code Example:
Code Explanation:
Imports:
System
, System.IO
, System.Net.Http
, and System.Threading.Tasks
are used for basic operations and HTTP requests.Newtonsoft.Json.Linq
is used for handling JSON responses.Main Method:
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
class Program
{
static async Task Main(string[] args)
{
string modelId = "microsoft/Phi-3-vision-128k-instruct";
string outDir = "model/phi3-vision/int4";
string imagePath = "./imgs/demo.png";
// Load the image
byte[] imageBytes = File.ReadAllBytes(imagePath);
// Prepare the request
var client = new HttpClient();
var requestContent = new MultipartFormDataContent();
requestContent.Add(new ByteArrayContent(imageBytes), "file", "demo.png");
// Send the request to the model
var response = await client.PostAsync($"https://api.example.com/models/{modelId}/predict", requestContent);
response.EnsureSuccessStatusCode();
// Process the response
var responseContent = await response.Content.ReadAsStringAsync();
var jsonResponse = JObject.Parse(responseContent);
// Output the result
Console.WriteLine("Generated Caption: " + jsonResponse["caption"]);
}
}
Note This example assumes you have an API endpoint for the Phi-3 Vision model. You might need to adjust the URL and other details based on your specific setup.
what about offline planning
How to use planner with phi 3 vision.Give an code example in c#.
sorry to bother you.I am new is this arena