# 13th Place Solution - A Kaggle beginner's attempt

Congratulations to the winners and all participants for their efforts!
I want to give a huge shoutout to
[@richolson](https://www.kaggle.com/richolson)
for his unbelievably educational and helpful notebook and discussion posts. I personally learned a lot from
[his notebook](https://www.kaggle.com/code/richolson/stable-diffusion-svg-scoring-metric)
and it was the starting point for my solution.
EDIT: I published my version of the
[notebook](https://www.kaggle.com/code/howarudo/13th-place-solution-flux-svg-scoring)
! Feel free to check it out!
Summary
'a'
for OCR mitigation
Optimized VTracer's bitmap -> SVG conversion with binary search and SVG compression
Used FLUX.1 Schnell and
[nunchaku quantization](https://github.com/mit-han-lab/nunchaku)
VQA with dummy question and answer
OCR mitigation
From previous discussions, we know that adding a letter to the iamge can reduce OCR hallucinations. I added the letter
'a'
to the bottom right corner of the image.
svg_a = """"""
![](assets/a246f4811c49ef9856d7fb43.png)
Bitmap to SVG conversion
Binary Search
In a
[public notebook](https://www.kaggle.com/code/dhurky/lb-0-52-sd-svg-conversion-using-vtracer)
, VTracer was used for SVG conversion but in that pipeline, the bitmap was resized to a constant smaller size to reduce the SVG size (10kB restriction). One improvement to this is to use binary search to find the maximum size to convert the bitmap to SVG without exceeding the 10kB limit.
SVG Compression
VTracer's output SVG looks like this:
Compression techniques:
Absolute to Relative Coordinates
: Convert absolute coordinates to relative coordinates in the SVG path.
Removing Transformations
: Remove unnecessary transformations like
translate
.
Longest path -> fill
: Convert the longest path to a fill rectangle.
This allows bitmaps to have be resized about 50px bigger than without compression. It does not affect images that are relatively SVG-friendly but it helps with images that are not.
![](assets/a7ffd742be4d47afb6152a1a.png)
![](assets/28aa4873bc1a37064dea13d1.png)
Image Generation
I used
[FLUX.1 Schnell](https://huggingface.co/black-forest-labs/FLUX.1-schnell)
for image generation and
[nunchaku](https://github.com/mit-han-lab/nunchaku)
for quantization. I tried base SD models, finetuning SDXL Lora but found that FLUX.1 Schnell has better prompt adherence. Also, with quantization, FLUX.1 Schnell is faster.
Dummy VQA
From 10-12 images generated, I evaluated the images using the questions below.
question = [
    ,
    
]
choices = [
    [, , , ],
    [, , ]
]
answer = [
    ,
    
]
In addition, I performed a linear regression on fidelity VQA scores using dummy VQA scores from an extended training set to predict the final VQA score.
$$VQA_{predicted} = w_1 * VQA_{dummy_1} + w_2 * VQA_{dummy_2} + b$$
Evaluating an image per question takes
< 2 seconds
while generating an image with FLUX.1 Schnell takes
~ 1 second
. Hence, I found that generating more images and evaluating them with 1-2 questions is more efficient than generating fewer images and evaluating them with 3-4 questions.
In Hindsight…
After reading
[@cnumber](https://www.kaggle.com/cnumber)
's post, I regret not trying
pydiffvg
to further optimize the scores and not trying Siglip. I also had moments where I wished I had participated in a team as it was difficult to come up with ideas solo. Regardless, I am happy with the knowledge and experience I gained from this competition!
PS: In future competitions, I hope to join a team to bounce ideas off each other so feel free to reach out if you happen to see me in a future competition!