Fix issue with getting captions on runpod
This commit is contained in:
parent
47002b067f
commit
7ab44ae0cd
|
|
@ -4,11 +4,15 @@ import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { getDatasetsRoot } from '@/server/settings';
|
import { getDatasetsRoot } from '@/server/settings';
|
||||||
|
|
||||||
export async function GET(request: NextRequest, { params }: { params: { imagePath: string } }) {
|
export async function POST(request: NextRequest) {
|
||||||
const { imagePath } = await params;
|
|
||||||
|
const body = await request.json();
|
||||||
|
const { imgPath } = body;
|
||||||
|
console.log('Received POST request for caption:', imgPath);
|
||||||
try {
|
try {
|
||||||
// Decode the path
|
// Decode the path
|
||||||
const filepath = decodeURIComponent(imagePath);
|
const filepath = imgPath;
|
||||||
|
console.log('Decoded image path:', filepath);
|
||||||
|
|
||||||
// caption name is the filepath without extension but with .txt
|
// caption name is the filepath without extension but with .txt
|
||||||
const captionPath = filepath.replace(/\.[^/.]+$/, '') + '.txt';
|
const captionPath = filepath.replace(/\.[^/.]+$/, '') + '.txt';
|
||||||
|
|
@ -33,7 +33,7 @@ const DatasetImageCard: React.FC<DatasetImageCardProps> = ({
|
||||||
if (isGettingCaption.current || isCaptionLoaded) return;
|
if (isGettingCaption.current || isCaptionLoaded) return;
|
||||||
isGettingCaption.current = true;
|
isGettingCaption.current = true;
|
||||||
apiClient
|
apiClient
|
||||||
.get(`/api/caption/${encodeURIComponent(imageUrl)}`)
|
.post(`/api/caption/get`, { imgPath: imageUrl })
|
||||||
.then(res => res.data)
|
.then(res => res.data)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Caption fetched:', data);
|
console.log('Caption fetched:', data);
|
||||||
|
|
@ -187,7 +187,7 @@ const DatasetImageCard: React.FC<DatasetImageCardProps> = ({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{inViewport && isVisible && (
|
{inViewport && isVisible && (
|
||||||
<div className="text-xs text-gray-100 bg-gray-950 mt-1 absolute bottom-0 left-0 p-1 opacity-25 hover:opacity-90 transition-opacity duration-300">
|
<div className="text-xs text-gray-100 bg-gray-950 mt-1 absolute bottom-0 left-0 p-1 opacity-25 hover:opacity-90 transition-opacity duration-300 w-full">
|
||||||
{imageUrl}
|
{imageUrl}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue