Upload FloorplanValidator model
Browse files- README.md +63 -0
- config.json +22 -0
- model.pt +3 -0
- transform.py +10 -0
README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- floorplan
|
| 5 |
+
- real-estate
|
| 6 |
+
- image-classification
|
| 7 |
+
datasets:
|
| 8 |
+
- custom
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# FloorplanValidator
|
| 12 |
+
|
| 13 |
+
This model distinguishes between floorplan images and non-floorplan images in real estate listings.
|
| 14 |
+
|
| 15 |
+
## Model Details
|
| 16 |
+
|
| 17 |
+
- Model type: ResNet50 fine-tuned for binary classification
|
| 18 |
+
- Task: Binary image classification
|
| 19 |
+
- Training data: Custom dataset of floorplan and non-floorplan images
|
| 20 |
+
- Class labels: 0 (floorplan), 1 (no_image)
|
| 21 |
+
|
| 22 |
+
## Intended Use
|
| 23 |
+
|
| 24 |
+
- Identify valid floorplan images in real estate listings
|
| 25 |
+
- Filter out non-floorplan images
|
| 26 |
+
|
| 27 |
+
## Usage
|
| 28 |
+
|
| 29 |
+
```python
|
| 30 |
+
from huggingface_hub import hf_hub_download
|
| 31 |
+
import torch
|
| 32 |
+
from PIL import Image
|
| 33 |
+
from torchvision import transforms
|
| 34 |
+
|
| 35 |
+
# Load model
|
| 36 |
+
model_path = hf_hub_download("acd20000/FloorplanValidator", "model.pt")
|
| 37 |
+
model = torch.load(model_path, map_location=torch.device('cpu'))
|
| 38 |
+
model.eval()
|
| 39 |
+
|
| 40 |
+
# Define transformation for input images
|
| 41 |
+
transform = transforms.Compose([
|
| 42 |
+
transforms.Resize((224, 224)),
|
| 43 |
+
transforms.ToTensor(),
|
| 44 |
+
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
|
| 45 |
+
])
|
| 46 |
+
|
| 47 |
+
# Load and transform an image
|
| 48 |
+
image = Image.open("your_image.jpg").convert('RGB')
|
| 49 |
+
input_tensor = transform(image).unsqueeze(0)
|
| 50 |
+
|
| 51 |
+
# Make prediction
|
| 52 |
+
with torch.no_grad():
|
| 53 |
+
output = model(input_tensor)
|
| 54 |
+
probabilities = torch.softmax(output, dim=1)
|
| 55 |
+
predicted_class = torch.argmax(probabilities, dim=1).item()
|
| 56 |
+
confidence = probabilities[0][predicted_class].item()
|
| 57 |
+
|
| 58 |
+
result = {
|
| 59 |
+
'class': "floorplan" if predicted_class == 0 else "non-floorplan",
|
| 60 |
+
'confidence': confidence
|
| 61 |
+
}
|
| 62 |
+
print(result)
|
| 63 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "image-classification",
|
| 3 |
+
"num_classes": 2,
|
| 4 |
+
"class_names": [
|
| 5 |
+
"floorplan",
|
| 6 |
+
"no_image"
|
| 7 |
+
],
|
| 8 |
+
"architecture": "resnet50",
|
| 9 |
+
"image_size": 224,
|
| 10 |
+
"transforms": {
|
| 11 |
+
"normalize_mean": [
|
| 12 |
+
0.485,
|
| 13 |
+
0.456,
|
| 14 |
+
0.406
|
| 15 |
+
],
|
| 16 |
+
"normalize_std": [
|
| 17 |
+
0.229,
|
| 18 |
+
0.224,
|
| 19 |
+
0.225
|
| 20 |
+
]
|
| 21 |
+
}
|
| 22 |
+
}
|
model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:81288a7a48ee5212bc5a0f218789ba6b8b208a9efa30767ddb100a33c9d21216
|
| 3 |
+
size 94371306
|
transform.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import torch
|
| 3 |
+
from torchvision import transforms
|
| 4 |
+
|
| 5 |
+
def get_transform():
|
| 6 |
+
return transforms.Compose([
|
| 7 |
+
transforms.Resize((224, 224)),
|
| 8 |
+
transforms.ToTensor(),
|
| 9 |
+
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
|
| 10 |
+
])
|