Skip to content

Commit

Permalink
feature: Component extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
linround committed Mar 12, 2024
1 parent a90a1d2 commit de0e0eb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
24 changes: 7 additions & 17 deletions src/AIModels/SDXLLightning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ import {SDXLLightningCredentials} from "./env.ts";
import {ImgComponent} from "../component/ImgComponent/ImgComponent.tsx";
import {useState} from "react";
import {AnyObject} from "../type/common.ts";
import css from './SDXLLightning.module.less'

fal.config({
credentials: SDXLLightningCredentials, // or a function that returns a string
});

const demoPrompt = [
'this is a photo,Next to a big river in the real world,The mouse and the lion are talking',
'moon'
]


// url: https://huggingface.co/ByteDance/SDXL-Lightning
export function SDXLLightning() {

// url: https://huggingface.co/ByteDance/SDXL-Lightning
interface SDXLLightningProps {
inputs: string
setInputs: React.Dispatch<React.SetStateAction<string>>
}
export function SDXLLightning(props:SDXLLightningProps) {
const {inputs,setInputs } = props
const [imgUrl,setImgUrl ] = useState<string>('')
const [inputs, setInputs] = useState<string>('')
const onClick = async () => {
const result = await fal.subscribe("110602490-fast-sdxl", {
input: {
Expand All @@ -37,21 +36,12 @@ export function SDXLLightning() {
setInputs(e.target.value)
}

const onClickDemo = (e:React.MouseEvent) => {
const target = e.target as HTMLDivElement;
setInputs(target.innerText)
}

return (
<div>
<div>
<ImgComponent src={imgUrl} />
</div>
<div onClick={onClickDemo}>
{demoPrompt.map((item,index) => {
return (<div className={css.demoItem} key={index}>{item}</div>)
})}
</div>

<div>
<input defaultValue={inputs} onChange={onChange}/>
Expand Down
9 changes: 7 additions & 2 deletions src/AIModels/UtilityPole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import React from "react";
import { useState } from 'react'
import {AnyObject} from "../type/common.ts";
import {ImgComponent} from "../component/ImgComponent/ImgComponent.tsx";
export function UtilityPole() {

interface UtilityPoleProps {
inputs: string
setInputs: React.Dispatch<React.SetStateAction<string>>
}
export function UtilityPole(props:UtilityPoleProps) {
const {inputs,setInputs } = props
const [imgUrl,setImgUrl ] = useState<string>('')
const [inputs, setInputs] = useState<string>('')
async function query(data:AnyObject) {
const response = await fetch(
"https://api-inference.huggingface.co/models/BotsOne/utilitypole",
Expand Down
21 changes: 19 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import './App.css'
import {UtilityPole} from "./AIModels/UtilityPole.tsx";
import {SDXLLightning} from "./AIModels/SDXLLightning.tsx";
import React, {useState} from "react";
import css from "./AIModels/SDXLLightning.module.less";

function App() {
const demoPrompt = [
'this is a photo,Next to a big river in the real world,The mouse and the lion are talking',
'a moon and a little girl'
]
const [inputs, setInputs] = useState<string>('')
const onClickDemo = (e:React.MouseEvent) => {
const target = e.target as HTMLDivElement;
setInputs(target.innerText)
}
return (
<>
<UtilityPole />
<SDXLLightning />

<div onClick={onClickDemo}>
{demoPrompt.map((item,index) => {
return (<div className={css.demoItem} key={index}>{item}</div>)
})}
</div>
<UtilityPole inputs={inputs} setInputs={setInputs} />
<SDXLLightning inputs={inputs} setInputs={setInputs} />
</>
)
}
Expand Down

0 comments on commit de0e0eb

Please sign in to comment.