NCA-GENM Question 144
Select 3You are tasked with writing a Python script to preprocess a multimodal dataset containing images and text under the guidance of a senior team member. The script is meant to resize images to 224x224 pixels and tokenize text descriptions. Which steps should you include in your script to ensure it meets the requirements?
- A
Use a library like PIL or OpenCV to resize images to 224x224 pixels.
- B
Write a custom algorithm to resize images without using external libraries.
- C
Use a tokenizer from a library like Hugging Face Transformers to tokenize text descriptions.
- D
Manually split text into individual words without leveraging prebuilt tokenization libraries.
- E
Validate the output for both images and text to ensure they align with the expected formats.
Show answer and explanation
Correct answers: A, C, E
Explanation
The correct steps involve leveraging existing libraries like PIL, OpenCV, and Hugging Face Transformers to handle common preprocessing tasks efficiently. Manually implementing solutions for resizing or tokenization is not recommended due to the availability of reliable, prebuilt tools. Additionally, validating the output is essential to ensure the data meets the specified requirements and aligns with the downstream tasks.
- A. Correct.
Using a library like PIL or OpenCV is a standard and efficient way to resize images while maintaining quality and consistency.
- B. Incorrect.
Writing a custom algorithm to resize images is unnecessary and inefficient when well-tested libraries already exist for this purpose.
- C. Correct.
Tokenizers from libraries like Hugging Face Transformers are specifically designed to handle text tokenization efficiently and accurately.
- D. Incorrect.
Manually splitting text into words is error-prone and does not account for complex tokenization requirements like handling punctuation and subwords.
- E. Correct.
Validating output ensures that the processed data meets the expected requirements, which is a critical step in building robust preprocessing pipelines.