Comments (2)
This is correct, the current resizing code does not preserve the aspect ratio. This requires changes in the resizePixelBuffer function.
from coremlhelpers.
Thanks for the response @hollance
What would the changes be? In OpenCV i do this resize procedure like this:
aspect_ratio = float(desired_size)/max(old_size)
new_size = tuple([int(x* aspect_ratio) for x in old_size])
im = cv2.resize(im, (new_size[1], new_size[0]))
// for the border
delta_w = desired_size - new_size[1]
delta_h = desired_size - new_size[0]
top, bottom = delta_h//2, delta_h-(delta_h//2)
left, right = delta_w//2, delta_w-(delta_w//2)
color = [0, 0, 0]
new_im = cv2.copyMakeBorder(im, top, bottom, left, right, cv2.BORDER_CONSTANT,
value=color)`
How could we port this to pixel buffer?
from coremlhelpers.
Related Issues (20)
- How to know if coreML model would perform image-preprocessing step or not?
- Q about output Multiarray shape
- Carthage - no shared framework schemes HOT 2
- Is there any evaluation example code or helper modules on this repo? HOT 1
- Accessing elements from Dim 5 multi array not working
- Swift Package Manager Support? HOT 2
- [Feature] MLMultiArray -> UIImage without premultiplied alpha HOT 2
- Prediction discrepancies between Python's coremltools and Swift's CoreML API HOT 4
- Need help to adjust bbox for cropped images HOT 7
- pixelBuffer not public HOT 1
- MLMultiarray+Image.swift file gives error HOT 1
- How to use the transposed function? from (26, 64, 48, 1) to (1, 26, 64, 48) HOT 3
- CoreGraphics resizing function from iOS (UIImage) to MacOS (NSImage) HOT 6
- PixelBuffer function from iOS (UIImage) to MacOS (NSImage) HOT 3
- UI Image to kCVPixelFormatType_422YpCbCr8FullRange pixel format not working HOT 4
- Add support for transpose with dataType int and float
- Change image to multiArray in case of converted mlmodel from TFlite
- Question about backprop HOT 5
- "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64"
- Custom Model Not Working Correctly in the Application HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coremlhelpers.