File size: 886 Bytes
ab3a358
 
 
 
 
e68ef55
 
 
 
ab3a358
e68ef55
ab3a358
e68ef55
 
 
 
 
ab3a358
 
e68ef55
 
ab3a358
e68ef55
 
 
 
ab3a358
e68ef55
ab3a358
e68ef55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from transformers import AutoImageProcessor, AutoModelForObjectDetection
from PIL import Image
import torch

# Modelo que detecta prendas de vestir
model_name = "yainage90/fashion-object-detection"
processor = AutoImageProcessor.from_pretrained(model_name)
model = AutoModelForObjectDetection.from_pretrained(model_name)

# Precios fijos por prenda (estimados)
PRECIOS = {
    'top': 7000,
    'bottom': 18000,
    'shoes': 25000,
    'bag': 15000,
    'outer': 22000
}

def estimar_precio(imagen):
    inputs = processor(images=imagen, return_tensors="pt")
    outputs = model(**inputs)

    target_size = [imagen.height, imagen.width]
    results = processor.post_process_object_detection(outputs, threshold=0.5, target_sizes=[target_size])[0]

    total = 0
    resumen = []

    for score, label, box in zip(results["scores"], results["labels"], results["box]()