This is a viewer only at the moment see the article on how this works.
To update the preview hit Ctrl-Alt-R (or ⌘-Alt-R on Mac) or Enter to refresh. The Save icon lets you save the markdown file to disk
This is a preview from the server running through my markdig pipeline
Monday, 24 November 2025
क्या आपके साइटों पर छवियों के लिए अविस्मरणीय पाठ हैं या उनसे जानकारी निकालने के लिए? mostlylucid.llmalttext Microsoft Lucus-2 दृष्टि मॉडल का उपयोग करके उच्च-रूप पाठ बनाने के लिए करें - आपके मशीन पर पूर्ण रूप से चल रहा है, कोई एपीआई कुंजियों की आवश्यकता नहीं है.
नोट: अब मुझे इस खुराक को अद्यतन करने की आवश्यकता है म्यूजेट पैकेज बाहर है. यदि आप देखते हैं यहाँ आप ठीक एक राजी डेमो साइट आप डाउनलोड कर सकते हैं और उपयोग कर सकते हैं। मैं आगामी दिनों में विवरणों के साथ यह अद्यतन करेंगे।
ऑल्ट पाठ विषय. स्क्रीन रीडर इस पर निर्भर करता है, यह पहुँच के लिए सही चीज़ है. लेकिन सैकड़ों छवियों के लिए अच्छी तरह से लिखा? यह जहां हम में से अधिकांश गिर जाता है.
यह पैकेज उस समस्या को हल करता है माइक्रोसॉफ्ट-2 दर्शन की भाषा मॉडल मॉडल - पूरी तरह से आपके मशीन पर चल रहा है, कोई एपीआई कुंजियों की आवश्यकता नहीं है.
स्रोत कोड: gtykh.com/sech/ loud.net
प्रत्येक <img> टैग को पूरा पाठ अर्थपूर्ण होना चाहिए. पर अभ्यास में:
क्या होगा अगर आप अपने खुद के हार्डवेयर पर पूरी तरह से चल सकते हैं?
पैकेज ऑन NNX चरण के माध्यम से माइक्रोसॉफ़्ट क्लीक्स मॉडल उपयोग करता है. यहाँ प्रक्रिया की प्रक्रिया है:
flowchart TB
subgraph Input[Image Sources]
A[File Path]
B[URL]
C[Stream]
D[Byte Array]
end
subgraph Processing[Florence-2 Pipeline]
E[Image Preprocessing]
F[Vision Encoder]
G[Language Decoder]
end
subgraph Output[Results]
H[Alt Text]
I[OCR Text]
J[Content Type]
end
A --> E
B --> E
C --> E
D --> E
E --> F
F --> G
G --> H
G --> I
G --> J
style A stroke:#10b981,stroke-width:2px
style B stroke:#10b981,stroke-width:2px
style C stroke:#10b981,stroke-width:2px
style D stroke:#10b981,stroke-width:2px
style F stroke:#6366f1,stroke-width:2px
style G stroke:#6366f1,stroke-width:2px
style H stroke:#ec4899,stroke-width:2px
style I stroke:#ec4899,stroke-width:2px
style J stroke:#ec4899,stroke-width:2px
कुंजी फीचर:
dotnet add package Mostlylucid.LlmAltText
// Program.cs
builder.Services.AddAltTextGeneration();
यह है. पहला रन 200 (0.0300MB) डाउनलोड, तो तुम जाने के लिए तैयार हो.
public class ImageController : ControllerBase
{
private readonly IImageAnalysisService _imageAnalysis;
public ImageController(IImageAnalysisService imageAnalysis)
{
_imageAnalysis = imageAnalysis;
}
[HttpPost("analyze")]
public async Task<IActionResult> Analyze(IFormFile image)
{
using var stream = image.OpenReadStream();
var altText = await _imageAnalysis.GenerateAltTextAsync(stream);
return Ok(new { altText });
}
}
सेवा जहाँ कहीं भी फ़ाइलों, यूआरएल, नदियाँ या बाइट क्रम से होती है, वहाँ से छवियों को स्वीकार करती है.
var altText = await _imageAnalysis.GenerateAltTextFromFileAsync("/images/photo.jpg");
var altText = await _imageAnalysis.GenerateAltTextFromUrlAsync(
"https://example.com/image.png");
using var stream = file.OpenReadStream();
var altText = await _imageAnalysis.GenerateAltTextAsync(stream);
var bytes = await httpClient.GetByteArrayAsync(imageUrl);
var altText = await _imageAnalysis.GenerateAltTextAsync(bytes);
क्लीएस- 2 तीन शीर्षक मोडों को समर्थित करता है. अपनी आवश्यकताओं पर आधारित चुनें:
// Brief - "A dog sitting on grass"
var brief = await _imageAnalysis.GenerateAltTextAsync(stream, "CAPTION");
// Detailed - "A golden retriever sitting on green grass in a park"
stream.Position = 0;
var detailed = await _imageAnalysis.GenerateAltTextAsync(stream, "DETAILED_CAPTION");
// Most detailed (default) - Full accessibility description
stream.Position = 0;
var full = await _imageAnalysis.GenerateAltTextAsync(stream, "MORE_DETAILED_CAPTION");
// "A happy golden retriever with light fur sitting on lush green grass
// in a sunny park, with trees visible in the background."
जब प्रत्येक इस्तेमाल किया जाए:
INBOX कार्य प्रकार Adrig के लिए उत्तम
|-----------|----------|
| CAPTION लघु छवि, सजावटी छवियाँ, तत्काल औज़ार- पट्टी
| DETAILED_CAPTION वबाल सामाजिक मीडिया, मूल पहुँच विस्तारक
| MORE_DETAILED_CAPTION ICS पूर्ण पहुंचनीयता, स्क्रीन रीडर (ऊर्ध्वाधर)
लूसिया- 2 से स्क्रीनशॉट, दस्तावेज़ों और चार्टों के लिए चित्र - उपयोगी पाठ भी निकाला जा सकता है ।
// Extract text only
var extractedText = await _imageAnalysis.ExtractTextAsync(stream);
// Get both alt text and extracted text
var (altText, ocrText) = await _imageAnalysis.AnalyzeImageAsync(stream);
Console.WriteLine($"Alt: {altText}");
Console.WriteLine($"OCR: {ocrText}");
सभी छवियों में एक समान नहीं है. एक तस्वीर को एक पूर्ण पाठ की जरूरत होती है; एक दस्तावेज़ को अपने पाठ सामग्री की ज़रूरत होती है. वर्ग विशेषता आपको हर उचित तरीके से काम करने में मदद करती है:
var result = await _imageAnalysis.AnalyzeWithClassificationAsync(stream);
Console.WriteLine($"Type: {result.ContentType}"); // e.g., "Photograph"
Console.WriteLine($"Confidence: {result.ContentTypeConfidence:P0}"); // e.g., "87%"
Console.WriteLine($"Has Text: {result.HasSignificantText}");
var result = await _imageAnalysis.AnalyzeWithClassificationAsync(stream);
switch (result.ContentType)
{
case ImageContentType.Document:
// Documents - prioritize extracted text
return result.ExtractedText;
case ImageContentType.Screenshot:
// Screenshots - combine description with UI text
return result.HasSignificantText
? $"{result.AltText}. Text visible: {result.ExtractedText}"
: result.AltText;
case ImageContentType.Chart:
// Charts - describe the visualization plus data
return $"{result.AltText}. Data: {result.ExtractedText}";
case ImageContentType.Photograph:
default:
// Photos - just the description
return result.AltText;
}
INBECKS विवरण आपस में बुरे उदाहरण
|------|-------------|---------|
| Photograph IMTARICONA( play), पार्क, उत्पादों का पुनः लोड किया
| Document INTAT पाठ- भारी PDF, फ़ॉर्म, आलेख लानत्स
| Screenshot libburn सॉफ्टवेयर कैप्चरs यूआई, वेबसाइट, एएसएसटी
| Chart नाहक़ डाटा दृश्य ग्राफ, पाई चार्ट, तालिका दुआएँ
| Illustration ऑस्कर सामग्री कलाकारी, कार्टून्स, प्रतीक टेरिट्रिक
| Diagram तमाम तकनीकी ड्राइंगों के लिए ऊबुन्टोफ्स, यूएमएल, प्रसंगेटिकस्
| Unknown STANATCKS किनारे के बारे में (_C)
यहाँ है जहां यह दिलचस्प हो जाता है. टैग मददर स्वचालित रूप से किसी भी के लिए एकले पाठ बनाता है <img> टैग एक - रेंडर समय में.
// Program.cs
builder.Services.AddAltTextGeneration(options =>
{
options.EnableTagHelper = true;
options.EnableDatabase = true; // Cache results
options.DbProvider = AltTextDbProvider.Sqlite;
options.SqliteDbPath = "./alttext.db";
});
var app = builder.Build();
await app.Services.MigrateAltTextDatabaseAsync();
टैग मदद करनेवाले को पंजीकृत करें _ViewImports.cshtml:
@addTagHelper *, Mostlylucid.LlmAltText
flowchart LR
subgraph Razor[Razor View Rendering]
A[img tag found]
B{Has alt attribute?}
C[Skip - use existing]
D{In cache?}
E[Return cached]
F[Fetch image]
G[Generate alt text]
H[Cache result]
I[Render with alt]
end
A --> B
B -->|Yes| C
B -->|No| D
D -->|Yes| E
D -->|No| F
F --> G
G --> H
H --> I
E --> I
style A stroke:#10b981,stroke-width:2px
style B stroke:#6366f1,stroke-width:2px
style G stroke:#ec4899,stroke-width:2px
style I stroke:#8b5cf6,stroke-width:2px
<!-- NO ALT - Will be processed -->
<img src="https://example.com/photo.jpg" />
<!-- HAS ALT - Skipped (respects your text) -->
<img src="https://example.com/photo.jpg" alt="My custom description" />
<!-- EMPTY ALT - Skipped (decorative image per a11y standards) -->
<img src="https://example.com/decorative.jpg" alt="" />
<!-- EXPLICIT SKIP - Skipped -->
<img src="https://example.com/photo.jpg" data-skip-alt="true" />
<!-- DATA URI - Skipped (can't fetch) -->
<img src="data:image/png;base64,..." />
<!-- RELATIVE PATH - Skipped (needs absolute URL) -->
<img src="/images/photo.jpg" />
सुरक्षा के लिए, आप पर प्रतिबंध लगा सकते हैं जो टैग- डोमेन से लाया जाएगा:
options.AllowedImageDomains = new List<string>
{
"mycdn.example.com",
"images.mysite.org",
"cdn.githubusercontent.com"
};
कैशिंग के बगैर, प्रत्येक पृष्ठ रेंडर एक स्क्रीन्लाइन पाठ फिर से प्रारंभ करेगा. यह धीमा और अनुचित है. डाटाबेस कैश कैश खराब होता है, छवि यूआरएल द्वारा कुंजी परिणाम देता है.
builder.Services.AddAltTextGeneration(options =>
{
options.EnableDatabase = true;
options.DbProvider = AltTextDbProvider.Sqlite;
options.SqliteDbPath = "./alttext.db";
options.CacheDurationMinutes = 60;
});
builder.Services.AddAltTextGeneration(options =>
{
options.EnableDatabase = true;
options.DbProvider = AltTextDbProvider.PostgreSql;
options.ConnectionString = Configuration.GetConnectionString("AltTextDb");
});
builder.Services.AddAltTextGeneration(options =>
{
// Model location (~800MB downloaded here)
options.ModelPath = "./models";
// Default task type for alt text generation
options.DefaultTaskType = "MORE_DETAILED_CAPTION";
// Maximum word count for alt text
options.MaxWords = 90;
// Enable detailed logging
options.EnableDiagnosticLogging = true;
// TagHelper settings
options.EnableTagHelper = true;
options.EnableDatabase = true;
options.AutoMigrateDatabase = true;
// Database provider
options.DbProvider = AltTextDbProvider.Sqlite;
options.SqliteDbPath = "alttext.db";
// or
options.DbProvider = AltTextDbProvider.PostgreSql;
options.ConnectionString = "Host=localhost;Database=alttext;...";
// Security
options.AllowedImageDomains = new List<string> { "cdn.example.com" };
options.SkipSrcPrefixes = new List<string> { "data:", "blob:" };
// Caching
options.CacheDurationMinutes = 60;
});
ब्लॉग पोस्ट आयात करते समय मैं इसका इस्तेमाल कैसे करूँ:
public class ImageProcessor
{
private readonly IImageAnalysisService _imageAnalysis;
private readonly ILogger<ImageProcessor> _logger;
public ImageProcessor(
IImageAnalysisService imageAnalysis,
ILogger<ImageProcessor> logger)
{
_imageAnalysis = imageAnalysis;
_logger = logger;
}
public async Task ProcessMarkdownImagesAsync(string markdownPath)
{
var imageDir = Path.Combine(Path.GetDirectoryName(markdownPath)!, "images");
if (!Directory.Exists(imageDir)) return;
var images = Directory.GetFiles(imageDir, "*.*")
.Where(f => IsImageFile(f));
foreach (var imagePath in images)
{
try
{
var result = await _imageAnalysis
.AnalyzeWithClassificationFromFileAsync(imagePath);
_logger.LogInformation(
"Processed {File}: {Type} ({Confidence:P0})",
Path.GetFileName(imagePath),
result.ContentType,
result.ContentTypeConfidence);
// Store alt text for later use
await SaveAltTextAsync(imagePath, result.AltText);
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Failed to process {File}", imagePath);
}
}
}
private static bool IsImageFile(string path)
{
var ext = Path.GetExtension(path).ToLowerInvariant();
return ext is ".jpg" or ".jpeg" or ".png" or ".gif" or ".webp" or ".bmp";
}
}
INVERTENTE जिस कीमत पर मुख्य मान रखा गया है |--------|--------------| SUMUNE पहला रनयर (0-208MB मॉडल डाउनलोड) Libisofs मॉडल लोड करता है 0. 3-3 सेकेंड का विस्तार मेट्रिक पर- छवि- प्लगइन 0. 500-2000msparaguay. kgm अतुल्यकालिक मेमोरी उपयोग 2GB+ अनुशंसित Libisofs के लिए डिस्क स्थान07 800MB
// 1. Register as Singleton (model load is expensive)
builder.Services.AddAltTextGeneration(); // Already singleton internally
// 2. Check readiness before processing
if (!_imageAnalysis.IsReady)
{
return StatusCode(503, "AI model still initializing");
}
// 3. Use cancellation tokens for timeouts
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var altText = await _imageAnalysis.GenerateAltTextFromUrlAsync(url, cts.Token);
// 4. Process in batches, not parallel (memory constraints)
foreach (var image in images)
{
await ProcessImageAsync(image); // Sequential is safer
}
पैकेज में बनाने का काम शामिल है :
builder.Services.AddOpenTelemetry()
.WithTracing(tracing =>
{
tracing.AddSource("Mostlylucid.LlmAltText");
});
ट्रेसिंग उपक्रम
llmalttext.generate_alt_textllmalttext.extract_textllmalttext.analyze_imagellmalttext.classify_content_typeमॉडल स्थिति में स्वास्थ्य जाँच जोड़ें:
public class AltTextHealthCheck : IHealthCheck
{
private readonly IImageAnalysisService _service;
public AltTextHealthCheck(IImageAnalysisService service)
=> _service = service;
public Task<HealthCheckResult> CheckHealthAsync(
HealthCheckContext context,
CancellationToken cancellationToken = default)
{
return Task.FromResult(_service.IsReady
? HealthCheckResult.Healthy("Florence-2 model ready")
: HealthCheckResult.Unhealthy("Model not initialized"));
}
}
// Registration
builder.Services.AddHealthChecks()
.AddCheck<AltTextHealthCheck>("alttext");
Error: Failed to download model files
समाधानः
ModelPath_imageAnalysis.IsReady // Returns false
समाधानः
समाधानः
MORE_DETAILED_CAPTION (डिफ़ॉल्ट)समाधानः
EnableTagHelper = true@addTagHelper में _ViewImports.cshtmlAllowedImageDomains कॉन्फ़िगरेशनएक प्रारंभ बिन्दु बनाता है. सबसे अच्छे परिणाम के लिए:
alt="" सिर्फ पढ़ने लायक छवियों के लिएMostlylucid.LlmAltText एआई- सत्ता आपके लिए एआई- शक्ति प्राप्त करता है। उत्पादों के बिना खर्च या गोपनीयता की चिंता के. टैग मददर यह विशेष रूप से आसान कर देता है यह और आप के लिए सक्षम करता है <img> टैग स्वचलित a पाठ प्राप्त करें.
पैकेज अप्रचलित (जनिक डोमेन) है, तो जो कुछ भी आप इसके साथ करना चाहते हैं.
© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.