Spaces:
Runtime error
Runtime error
Delete App.js
Browse files
App.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
// src/App.js
|
| 2 |
-
import React, { useState } from 'react';
|
| 3 |
-
import axios from 'axios';
|
| 4 |
-
|
| 5 |
-
function App() {
|
| 6 |
-
const [generatedCaption, setGeneratedCaption] = useState('');
|
| 7 |
-
const [audioPath, setAudioPath] = useState('');
|
| 8 |
-
|
| 9 |
-
const handleImageUpload = async (event) => {
|
| 10 |
-
const formData = new FormData();
|
| 11 |
-
formData.append('image', event.target.files[0]);
|
| 12 |
-
|
| 13 |
-
try {
|
| 14 |
-
const response = await axios.post('https://api-inference.huggingface.co/models/Kamonwan/blip-image-captioning-new', formData);
|
| 15 |
-
// Extract the generated caption and audio path from the response
|
| 16 |
-
const { generated_caption, audio_path } = response.data;
|
| 17 |
-
setGeneratedCaption(generated_caption);
|
| 18 |
-
setAudioPath(audio_path);
|
| 19 |
-
} catch (error) {
|
| 20 |
-
console.error('Error uploading image:', error);
|
| 21 |
-
}
|
| 22 |
-
};
|
| 23 |
-
|
| 24 |
-
return (
|
| 25 |
-
<div>
|
| 26 |
-
<input type="file" onChange={handleImageUpload} />
|
| 27 |
-
<p>Generated Caption: {generatedCaption}</p>
|
| 28 |
-
<audio controls src={audioPath} />
|
| 29 |
-
</div>
|
| 30 |
-
);
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
export default App;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|