If you're trying to slim down, you might be entirely cutting out some of your favorite (perhaps not-so-healthy) foods-thinking that not eating treats will help you lose weight.

However, restricting foods that you enjoy can actually make you overindulge in them later, potentially undoing all your recent healthy-eating efforts, according to a study published in Proceedings of the National Academy of Science. You might not be successful at losing weight, despite your best intentions.

The lesson? You can keep your favorite foods around while slimming down. Here's how to keep those favorite foods in your diet.

For the bacon lover, the trick to enjoying bacon is to use it as a garnish. Instead of piling on pieces of bacon, add just a bit to healthy dishes-you'll still get that salty-smoky flavor you love.

While bacon makes a great addition to soups and baked potatoes, get creative with it and try it in dishes like this sautéed Brussels sprouts with bacon and onions (pictured) or this broccoli-bacon salad recipe. And while bacon's not a "diet" food, it certainly can be a part of any diet when eaten in smaller amounts.

Find more healthy bacon recipe ideas here.

Fried Foods
Deep-fried foods are notoriously unhealthy-they're coated and breaded and then fried in oil. They typically soak up a lot of oil, which delivers a lot of calories. Instead, try this trick to serve up healthier fried foods that can fit in your diet, too: use your oven!

With a light bread coating, a spritz of oil and an oven, you'll get crispy and delicious "fried" foods without the added calories and fat of traditional fried favorites. From onion rings and fried zucchini to this fried green tomato sandwich with rémoulade sauce, your favorites, even while you're trying to lose weight, are just a quick bake away!

While nuts are high in fat and calories, they aren't a fattening food and there's no need to cut them out of your diet when you're trying to lose weight. Nuts contain healthy fats and they're packed with protein, which can help stave off hunger.

When people ate ½ cup of walnuts daily for four months, they didn't gain weight and they had smaller waist sizes, according to research published in the Journal of the American College of Nutrition. Since nuts are high in calories, you may want to measure out a serving to eat rather than snacking straight from the jar or bowl (which might cause you to eat more).

Carbs-and pasta in particular-have an undeserved bad reputation when it comes to weight loss. The problem with pasta is, most people eat more than one serving at a time. (Have you seen a restaurant portion lately? Most could feed a family of four.) Eating too much of anything is bad for your waistline, and pasta is no exception.

Two tricks to keeping pasta in your diet while you're also trying to lose weight: choose whole-grain pasta and lighten it up. By swapping out the refined "regular" pasta in your pantry for whole-grain varieties, you'll get more fiber (which helps keep you full) and other nutrients. Add a little lean protein and plenty of veggies to your pasta dish to make it even more satisfying. The next time you crave pasta, try one of these low-calorie pasta dishes!

Thinking about swearing off chocolate forever? Forget about it! For many people, chocolate is a favorite-and it's not hard to see why. It's creamy, smooth and sweet. And enjoying it in small amounts may be the secret to losing weight.

Trying to be "perfect" with your diet is unattainable-most dieters who attempt perfection end up failing and going right back to where they started. Instead of throwing in the towel, make room for small treats (here are three 100-calorie chocolate favorites). Plus, dark chocolate actually has heart-healthy antioxidants. A double win.

As with the rest of these foods, don't go overboard-little bit of good chocolate can go a long way in satisfying your sweet tooth.