Add User Input Image Support
Users can now supply the --input argument to load their image by default to the application.
This commit is contained in:
22
lama_cleaner/app/src/components/hooks/useInputImage.js
Normal file
22
lama_cleaner/app/src/components/hooks/useInputImage.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
|
||||
export default function useInputImage() {
|
||||
const [inputImage, setInputImage] = useState()
|
||||
|
||||
const fetchInputImage = useCallback(() => {
|
||||
fetch('/inputimage')
|
||||
.then(res => res.blob())
|
||||
.then(data => {
|
||||
if (data && data.type.startsWith('image')) {
|
||||
const userInput = new File([data], 'inputImage')
|
||||
setInputImage(userInput)
|
||||
}
|
||||
})
|
||||
}, [setInputImage])
|
||||
|
||||
useEffect(() => {
|
||||
fetchInputImage()
|
||||
}, [])
|
||||
|
||||
return inputImage
|
||||
}
|
||||
Reference in New Issue
Block a user