Skip to content

Commit

Permalink
feat: auto compare when image changed and update initial models (#7)
Browse files Browse the repository at this point in the history
* feat: auto compare when image changed

* feat: change initial upscale models
  • Loading branch information
aykutkardas authored Mar 6, 2024
1 parent 7c9e7a2 commit 2647b7c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
16 changes: 9 additions & 7 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function UpscalerBattleground() {

let inferenceTime;

const resizedImage = await resizeImage(file, 512);
const resizedImage = await resizeImage(file);
const result: Record<string, any> = await fal.subscribe(firstModel.model, {
input: {
image_url: resizedImage,
Expand Down Expand Up @@ -85,7 +85,7 @@ export default function UpscalerBattleground() {

let inferenceTime;

const resizedImage = await resizeImage(file, 512);
const resizedImage = await resizeImage(file);
const result: Record<string, any> = await fal.subscribe(secondModel.model, {
input: {
image_url: resizedImage,
Expand Down Expand Up @@ -121,13 +121,15 @@ export default function UpscalerBattleground() {
if (image) {
const blobUrl = URL.createObjectURL(image);
setOriginalImage(blobUrl);
handleCompare(image);
}
};
const handleCompare = async () => {
if (!imageFile) return;

upscaleWithFirstModel(imageFile);
upscaleWithSecondModel(imageFile);
const handleCompare = async (image) => {
if (!image) return;

upscaleWithFirstModel(image);
upscaleWithSecondModel(image);
};

useEffect(() => {
Expand Down Expand Up @@ -189,7 +191,7 @@ export default function UpscalerBattleground() {
<Button
size="lg"
className="mx-auto md:mx-0"
onClick={handleCompare}
onClick={() => handleCompare(imageFile)}
disabled={!imageFile || firstModelLoading || secondModelLoading}
>
Compare
Expand Down
2 changes: 1 addition & 1 deletion components/model-compare.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cn, formatTime } from "@/lib/utils";
import { cn } from "@/lib/utils";
import Image from "next/image";
import {
ReactCompareSlider,
Expand Down
12 changes: 6 additions & 6 deletions components/model-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export const UPSCALE_MODELS: Model[] = [
model: "fal-ai/ccsr",
link: "https://fal.ai/models/ccsr",
},
{
shortname: "ESRGAN",
name: "ESRGAN Upscaler",
model: "fal-ai/esrgan",
link: "https://fal.run/fal-ai/esrgan",
},
{
shortname: "SUPIR",
name: "SUPIR Upscaler",
Expand All @@ -37,12 +43,6 @@ export const UPSCALE_MODELS: Model[] = [
model: "fal-ai/creative-upscaler",
link: "https://fal.ai/models/creative-upscaler",
},
{
shortname: "ESRGAN",
name: "ESRGAN Upscaler",
model: "fal-ai/esrgan",
link: "https://fal.run/fal-ai/esrgan",
},
];

export function ModelDropdown({
Expand Down

0 comments on commit 2647b7c

Please sign in to comment.